diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml index a82eff7..4c10e3a 100644 --- a/.github/workflows/release-assets.yml +++ b/.github/workflows/release-assets.yml @@ -17,7 +17,7 @@ jobs: - os: macos-latest arch: [arm64, amd64] - os: windows-latest - arch: amd64 + arch: [arm64, amd64] steps: - name: Check out Git repository uses: actions/checkout@v3 @@ -66,4 +66,4 @@ jobs: dist-release/*.yml dist-release/*.blockmap env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/electron-builder.json b/electron-builder.json index 93de530..3d140a1 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -15,7 +15,7 @@ "updaterCacheDirName": "escrcpy-updater" }, "nsis": { - "artifactName": "${productName}-${version}-win-setup.${ext}", + "artifactName": "${productName}-${version}-win-setup-${arch}.${ext}", "shortcutName": "${productName}", "uninstallDisplayName": "${productName}", "oneClick": false, @@ -24,7 +24,7 @@ "deleteAppDataOnUninstall": false }, "portable": { - "artifactName": "${productName}-${version}-win-portable.${ext}", + "artifactName": "${productName}-${version}-win-portable-${arch}.${ext}", "requestExecutionLevel": "user" }, "win": { @@ -32,17 +32,18 @@ "target": [ { "target": "nsis", - "arch": ["x64"] + "arch": ["x64", "arm64"] }, { "target": "zip", - "arch": ["x64"] + "arch": ["x64", "arm64"] }, { "target": "portable", - "arch": ["x64"] + "arch": ["x64", "arm64"] } ], + "artifactName": "${productName}-${version}-win-${arch}.${ext}", "extraResources": { "from": "electron/resources/extra", "to": "extra" diff --git a/electron/configs/index.js b/electron/configs/index.js index 2509fc0..8e5682f 100644 --- a/electron/configs/index.js +++ b/electron/configs/index.js @@ -11,6 +11,9 @@ export const logoPath = buildResolve('logo.png') export const icoLogoPath = buildResolve('logo.ico') export const icnsLogoPath = buildResolve('logo.icns') +export const trayPath = extraResolve('tray.png') +export const macTrayPath = extraResolve('tray-Template.png') + export const adbPath = process.platform === 'win32' ? extraResolve('core/adb.exe') diff --git a/electron/events/index.js b/electron/events/index.js index 12e4f91..3f3f9c0 100644 --- a/electron/events/index.js +++ b/electron/events/index.js @@ -5,12 +5,11 @@ import handles from './handles/index.js' import tray from './tray/index.js' export default (mainWindow) => { - handles(mainWindow) - updater(mainWindow) - tray(mainWindow) - ipcMain.on('restart-app', () => { app.relaunch() app.quit() }) + handles(mainWindow) + updater(mainWindow) + tray(mainWindow) } diff --git a/electron/events/tray/index.js b/electron/events/tray/index.js index 6e4c7d4..bc1a20c 100644 --- a/electron/events/tray/index.js +++ b/electron/events/tray/index.js @@ -1,5 +1,5 @@ import { Menu, Tray, app, dialog } from 'electron' -import { logoPath } from '@electron/configs/index' +import { macTrayPath, trayPath } from '@electron/configs/index' import appStore from '@electron/helpers/store.js' export default (mainWindow) => { @@ -29,7 +29,9 @@ export default (mainWindow) => { else if (response === 1) { mainWindow.hide() - tray = new Tray(logoPath) + const trayIcon = process.platform === 'darwin' ? macTrayPath : trayPath + + tray = new Tray(trayIcon) tray.setToolTip('escrcpy') @@ -44,6 +46,13 @@ export default (mainWindow) => { showApp() }, }, + { + label: '重启服务', + click: () => { + app.relaunch() + quitApp() + }, + }, { label: '退出', click: () => { @@ -84,8 +93,8 @@ export default (mainWindow) => { checkboxLabel: '是否记住选择?', }) - console.log('response', response) - console.log('checkboxChecked', checkboxChecked) + // console.log('response', response) + // console.log('checkboxChecked', checkboxChecked) if (checkboxChecked) { appStore.set('appCloseCode', response) diff --git a/electron/helpers/index.js b/electron/helpers/index.js index 9ced8f0..df3dd18 100644 --- a/electron/helpers/index.js +++ b/electron/helpers/index.js @@ -10,7 +10,7 @@ export const extraResolve = (value) => { } export const buildResolve = value => - resolve(`electron/resources/build/${value}`) + resolve(process.env.CWD, `electron/resources/build/${value}`) export function exposeContext(key, value) { if (process.contextIsolated) { diff --git a/electron/helpers/process.js b/electron/helpers/process.js index 5e00763..bddb7db 100644 --- a/electron/helpers/process.js +++ b/electron/helpers/process.js @@ -11,3 +11,5 @@ if (process.platform === 'darwin') { process.env.IS_PACKAGED = JSON.stringify(app.isPackaged) process.env.DESKTOP_PATH = app.getPath('desktop') + +process.env.CWD = process.cwd() diff --git a/electron/resources/extra/tray-Template.png b/electron/resources/extra/tray-Template.png new file mode 100644 index 0000000..7274ac5 Binary files /dev/null and b/electron/resources/extra/tray-Template.png differ diff --git a/electron/resources/extra/tray.png b/electron/resources/extra/tray.png new file mode 100644 index 0000000..7274ac5 Binary files /dev/null and b/electron/resources/extra/tray.png differ