Explorar el Código

Merge branch 'feature/v4.2-new' into develop

oldj hace 1 año
padre
commit
8cc6e0ecbd

+ 1 - 1
app/package.json

@@ -1,7 +1,7 @@
 {
   "name": "switchhosts",
   "productName": "SwitchHosts",
-  "version": "4.2.0.6105",
+  "version": "4.2.0.6119",
   "description": "Switch hosts quickly!",
   "main": "./main.js",
   "author": {

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 316 - 345
package-lock.json


+ 54 - 54
package.json

@@ -6,12 +6,12 @@
     "clean:dist": "rimraf ./dist/*",
     "clean:build": "rimraf ./build/*",
     "dev": "npm run clean:build && concurrently \"npm run dev:main\" \"npm run dev:renderer\"",
-    "dev:main": "vite build --watch --config ./vite.main.config.ts",
-    "dev:renderer": "vite --config ./vite.render.config.ts",
+    "dev:main": "vite build --watch --config ./vite.main.config.mts",
+    "dev:renderer": "vite --config ./vite.render.config.mts",
     "version:up": "node ./scripts/version_up.js",
     "_build": "npm run clean:build && npm run version:up && concurrently \"npm run build:main\" \"npm run build:renderer\"",
-    "build:main": "cross-env NODE_ENV=production vite build --config ./vite.main.config.ts",
-    "build:renderer": "cross-env NODE_ENV=production vite build --config ./vite.render.config.ts",
+    "build:main": "cross-env NODE_ENV=production vite build --config ./vite.main.config.mts",
+    "build:renderer": "cross-env NODE_ENV=production vite build --config ./vite.render.config.mts",
     "build": "npm run _build",
     "make": "node scripts/make.js",
     "make:dev": "cross-env SKIP_NOTARIZATION=1 cross-env MAKE_FOR=dev npm run make",
@@ -20,69 +20,69 @@
     "publish": "electron-builder --mac --win --linux -p always"
   },
   "dependencies": {
-    "axios": "1.6.0",
-    "compare-versions": "5.0.3",
-    "dayjs": "1.11.7",
-    "electron-updater": "5.3.0",
+    "axios": "1.7.2",
+    "compare-versions": "6.1.1",
+    "dayjs": "1.11.12",
+    "electron-updater": "6.3.0",
     "electron-window-state": "5.0.3",
     "express": "4.19.2",
     "lodash": "4.17.21",
     "md5": "2.3.0",
     "md5-file": "5.0.0",
-    "mkdirp": "3.0.0",
-    "potdb": "2.5.5",
-    "tslib": "2.5.0",
-    "uuid": "9.0.0"
+    "mkdirp": "3.0.1",
+    "potdb": "2.6.6",
+    "tslib": "2.6.3",
+    "uuid": "10.0.0"
   },
   "devDependencies": {
-    "@chakra-ui/react": "2.5.5",
-    "@emotion/react": "11.10.6",
-    "@emotion/styled": "11.10.6",
-    "@tabler/icons-react": "2.16.0",
-    "@types/assert": "1.5.6",
-    "@types/codemirror": "5.60.7",
-    "@types/express": "4.17.17",
-    "@types/lodash": "4.14.194",
-    "@types/md5": "2.3.2",
+    "@chakra-ui/react": "2.8.2",
+    "@electron/notarize": "^2.3.2",
+    "@emotion/react": "11.13.0",
+    "@emotion/styled": "11.13.0",
+    "@tabler/icons-react": "3.11.0",
+    "@types/assert": "1.5.10",
+    "@types/codemirror": "5.60.15",
+    "@types/express": "4.17.21",
+    "@types/lodash": "4.17.7",
+    "@types/md5": "2.3.5",
     "@types/mkdirp": "1.0.2",
-    "@types/mocha": "10.0.1",
-    "@types/node": "18.15.11",
-    "@types/react": "18.0.35",
-    "@types/react-dom": "18.0.11",
-    "@types/react-window": "1.8.5",
-    "@types/uuid": "9.0.1",
-    "@vitejs/plugin-react": "3.1.0",
-    "ahooks": "3.7.6",
-    "clsx": "1.2.1",
-    "codemirror": "5.65.11",
-    "concurrently": "8.0.1",
+    "@types/mocha": "10.0.7",
+    "@types/node": "22.0.0",
+    "@types/react": "18.3.3",
+    "@types/react-dom": "18.3.0",
+    "@types/react-window": "1.8.8",
+    "@types/uuid": "10.0.0",
+    "@vitejs/plugin-react": "4.3.1",
+    "ahooks": "3.8.0",
+    "clsx": "2.1.1",
+    "codemirror": "5.65.17",
+    "concurrently": "8.2.2",
     "cross-env": "7.0.3",
-    "dotenv": "16.0.3",
-    "electron": "24.8.5",
+    "dotenv": "16.4.5",
+    "electron": "30.1.2",
     "electron-builder": "24.13.3",
-    "electron-notarize": "1.2.1",
     "espower-typescript": "10.0.1",
-    "execa": "7.1.1",
-    "fs-extra": "11.1.1",
-    "jotai": "2.0.4",
-    "mocha": "10.2.0",
+    "execa": "9.3.0",
+    "fs-extra": "11.2.0",
+    "jotai": "2.9.1",
+    "mocha": "10.7.0",
     "power-assert": "1.6.1",
-    "prettier": "2.8.7",
-    "pretty-bytes": "6.1.0",
-    "react": "18.2.0",
-    "react-dom": "18.2.0",
-    "react-icons": "4.8.0",
-    "react-router-dom": "6.10.0",
-    "react-window": "1.8.8",
-    "rimraf": "^5.0.0",
-    "sass": "1.62.0",
-    "smooth-scroll-into-view-if-needed": "2.0.0",
-    "ts-node": "10.9.1",
-    "typescript": "5.0.4",
+    "prettier": "3.3.3",
+    "pretty-bytes": "6.1.1",
+    "react": "18.3.1",
+    "react-dom": "18.3.1",
+    "react-icons": "5.2.1",
+    "react-router-dom": "6.25.1",
+    "react-window": "1.8.10",
+    "rimraf": "^6.0.1",
+    "sass": "1.77.8",
+    "smooth-scroll-into-view-if-needed": "2.0.2",
+    "ts-node": "10.9.2",
+    "typescript": "5.5.4",
     "vite": "4.5.3",
-    "vite-plugin-static-copy": "0.13.1",
-    "vite-plugin-svgr": "2.4.0",
-    "vite-tsconfig-paths": "4.2.0"
+    "vite-plugin-static-copy": "1.0.6",
+    "vite-plugin-svgr": "4.2.0",
+    "vite-tsconfig-paths": "4.3.2"
   },
   "build": {
     "afterSign": "scripts/notarize.js"

+ 23 - 40
scripts/make.js

@@ -1,57 +1,36 @@
 /**
- * make
+ * make.js
  * @author: oldj
  * @homepage: https://oldj.net
  */
 
 require('dotenv').config()
+const path = require('path')
+const fse = require('fs-extra')
 const version = require('../src/version.json')
 const builder = require('electron-builder')
-const fse = require('fs-extra')
 const homedir = require('os').homedir()
-const path = require('path')
-
-const root_dir = path.normalize(path.join(__dirname, '..'))
-const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
-
-const electronLanguages = ['en', 'fr', 'zh_CN', 'de', 'ja', 'tr', 'ko']
+const { APP_NAME, root_dir, dist_dir, electronLanguages } = require('./vars')
 
 const TARGET_PLATFORMS_configs = {
   mac: {
-    mac: ['default'],
-  },
-  macs: {
     mac: ['dmg:x64', 'dmg:arm64'],
   },
-  linux: {
-    linux: [
-      'AppImage:x64',
-      'deb:x64',
-      'AppImage:arm64',
-      'deb:arm64',
-      'AppImage:armv7l',
-      'deb:armv7l',
-    ],
-  },
   win: {
-    win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
+    win: ['nsis:ia32', 'nsis:x64', 'nsis:arm64', 'portable:x64'],
+  },
+  linux: {
+    linux: ['AppImage:x64', 'AppImage:arm64', 'deb:x64', 'deb:arm64'],
   },
   all: {
-    mac: ['dmg:x64', 'dmg:arm64'],
-    linux: [
-      'AppImage:x64',
-      'deb:x64',
-      'AppImage:arm64',
-      'deb:arm64',
-      'AppImage:armv7l',
-      'deb:armv7l',
-    ],
-    win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
+    mac: ['dmg:x64', 'dmg:arm64', 'zip:universal'],
+    win: ['nsis:ia32', 'nsis:x64', 'nsis:arm64', 'portable:x64', 'zip:x64' /* , 'appx:x64'*/],
+    linux: ['AppImage:x64', 'AppImage:arm64', 'deb:x64', 'deb:arm64'],
   },
 }
 
-const APP_NAME = 'SwitchHosts'
-const { IDENTITY } = process.env
+const { APP_BUNDLE_ID, IDENTITY } = process.env
+console.log(`APP_BUNDLE_ID: ${APP_BUNDLE_ID}`)
 
 const cfg_common = {
   copyright: `Copyright © ${new Date().getFullYear()}`,
@@ -62,8 +41,9 @@ const cfg_common = {
   },
   electronDownload: {
     cache: path.join(homedir, '.electron'),
-    mirror: 'https://npm.taobao.org/mirrors/electron/',
+    mirror: 'https://registry.npmmirror.com/-/binary/electron/',
   },
+  asar: true,
 }
 
 const beforeMake = async () => {
@@ -104,14 +84,12 @@ const doMake = async () => {
   let targets = TARGET_PLATFORMS_configs.all
 
   cfg_common.compression = 'maximum'
-  if (MAKE_FOR && MAKE_FOR !== 'all') {
-    cfg_common.compression = 'store'
-  }
 
   if (MAKE_FOR === 'dev') {
     targets = TARGET_PLATFORMS_configs.mac
+    cfg_common.compression = 'store'
   } else if (MAKE_FOR === 'mac') {
-    targets = TARGET_PLATFORMS_configs.macs
+    targets = TARGET_PLATFORMS_configs.mac
   } else if (MAKE_FOR === 'win') {
     targets = TARGET_PLATFORMS_configs.win
   } else if (MAKE_FOR === 'linux') {
@@ -140,6 +118,7 @@ const doMake = async () => {
           CFBundleLocalizations: electronLanguages,
           CFBundleDevelopmentRegion: 'en',
         },
+        notarize: false,
       },
       dmg: {
         //backgroundColor: '#f1f1f6',
@@ -173,6 +152,8 @@ const doMake = async () => {
         installerIcon: 'assets/installer-icon.ico',
         oneClick: false,
         allowToChangeInstallationDirectory: true,
+        deleteAppDataOnUninstall: false,
+        shortcutName: 'SwitchHosts',
         artifactName: '${productName}_windows_installer_${arch}_${version}(${buildVersion}).${ext}',
       },
       portable: {
@@ -205,8 +186,10 @@ const doMake = async () => {
     await beforeMake()
     await doMake()
     await afterMake()
+    //await macSign()
+
     console.log('-> make Done!')
   } catch (e) {
-    console.error(e)
+    console.log(e)
   }
 })()

+ 29 - 6
scripts/notarize.js

@@ -5,7 +5,21 @@
  */
 
 require('dotenv').config()
-const { notarize } = require('electron-notarize')
+const { notarize } = require('@electron/notarize')
+const { exec } = require('child_process')
+
+function getPasswordFromKeychain(account, service) {
+  return new Promise((resolve, reject) => {
+    const command = `security find-generic-password -a '${account}' -s '${service}' -w`
+    exec(command, (error, stdout, stderr) => {
+      if (error) {
+        reject(new Error(`Error fetching password: ${stderr}`))
+      } else {
+        resolve(stdout.trim())
+      }
+    })
+  })
+}
 
 exports.default = async function notarizing(context) {
   const appName = context.packager.appInfo.productFilename
@@ -21,23 +35,32 @@ exports.default = async function notarizing(context) {
   }
 
   let appPath = `${appOutDir}/${appName}.app`
-  let { appleId, appBundleId, ascProvider, appleIdPassword } = process.env
+  let {
+    APP_BUNDLE_ID: appBundleId,
+    TEAM_ID: teamId,
+    APPLE_ID: appleId,
+    APPLE_APP_SPECIFIC_PASSWORD: appleIdPassword,
+  } = process.env
   if (!appleIdPassword) {
-    appleIdPassword = `@keychain:Apple Notarize: ${appleId}`
+    //appleIdPassword = `@keychain:"Apple Notarize: ${appleId}"`
+    appleIdPassword = await getPasswordFromKeychain(appleId, `Apple Notarize: ${appleId}`)
+    process.env.APPLE_APP_SPECIFIC_PASSWORD = appleIdPassword
   }
 
-  if (!appleId || !appBundleId || !ascProvider || !appleIdPassword) {
+  if (!appleId || !appBundleId || !teamId || !appleIdPassword) {
     console.log('Not notarized.')
     return
   }
 
   console.log('Start notarizing...')
   await notarize({
-    appBundleId,
     appPath,
-    ascProvider,
+    tool: 'notarytool',
+    //appBundleId,
+    //ascProvider,
     appleId,
     appleIdPassword,
+    teamId,
   })
   console.log('Notarize done.')
 }

+ 15 - 0
scripts/vars.js

@@ -0,0 +1,15 @@
+const path = require('path')
+
+const root_dir = path.normalize(path.join(__dirname, '..'))
+const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
+
+const APP_NAME = 'SwitchHosts'
+
+const electronLanguages = ['en', 'fr', 'zh_CN', 'de', 'ja', 'tr', 'ko']
+
+module.exports = {
+  APP_NAME,
+  root_dir,
+  dist_dir,
+  electronLanguages,
+}

+ 1 - 0
src/renderer/components/List/ListItem.module.scss

@@ -77,6 +77,7 @@
   flex: 0 0 auto;
   display: flex;
   align-items: center;
+  gap: 5px;
   margin: auto 6px auto auto;
 }
 

+ 1 - 0
src/renderer/index.tsx

@@ -11,6 +11,7 @@ import React from 'react'
 import { createRoot } from 'react-dom/client'
 import { createHashRouter, RouterProvider } from 'react-router-dom'
 import { ChakraProvider, ColorModeScript } from '@chakra-ui/react'
+import './styles/common.scss'
 import theme from './theme'
 
 const router = createHashRouter([

+ 1 - 1
src/renderer/pages/find.tsx

@@ -254,7 +254,7 @@ const find = () => {
         scrollIntoView(el.current, {
           behavior: 'smooth',
           scrollMode: 'if-needed',
-        }).catch((e) => console.error(e))
+        })
       }
     }, [el, current_result_idx, last_scroll_result_idx])
 

+ 0 - 17
src/renderer/styles/common.scss

@@ -1,19 +1,2 @@
 @import "fn";
 
-html, body {
-  margin: 0;
-  padding: 0;
-  font-size: 14px;
-  line-height: 1.5em;
-  box-sizing: border-box;
-  color: var(--swh-font-color);
-  color-scheme: var(--swh-color-scheme);
-}
-
-button, a, input {
-  &:focus:not(:focus-visible) {
-    outline: 0;
-    box-shadow: none;
-  }
-}
-

+ 16 - 0
src/renderer/styles/global.scss

@@ -0,0 +1,16 @@
+html, body {
+  margin: 0;
+  padding: 0;
+  font-size: 14px;
+  line-height: 1.5em;
+  box-sizing: border-box;
+  color: var(--swh-font-color);
+  color-scheme: var(--swh-color-scheme);
+}
+
+button, a, input {
+  &:focus:not(:focus-visible) {
+    outline: 0;
+    box-shadow: none;
+  }
+}

+ 1 - 1
src/version.json

@@ -1 +1 @@
-[4, 2, 0, 6105]
+[4, 2, 0, 6119]

+ 0 - 0
vite.main.config.ts → vite.main.config.mts


+ 1 - 9
vite.render.config.ts → vite.render.config.mts

@@ -6,15 +6,7 @@ import tsconfigPaths from 'vite-tsconfig-paths'
 
 // https://vitejs.dev/config/
 export default defineConfig({
-  plugins: [
-    tsconfigPaths(),
-    svgr({
-      // Set it to `true` to export React component as default.
-      // Notice that it will overrides the default behavior of Vite.
-      exportAsDefault: true,
-    }),
-    react(),
-  ],
+  plugins: [tsconfigPaths(), svgr({}), react()],
   base: './',
   root: path.join(__dirname, 'src', 'renderer'),
   build: {

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio