From 1bed05b57cdbfa402d2ad017c51e6b34e64d4387 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Fri, 25 Apr 2025 18:13:07 +0800 Subject: [PATCH] fix: update electron-updater to patch to support window arm upgrade (#5337) --- ...lectron-updater-npm-6.6.3-9269dbaf84.patch | 38 +++++++++++++++++++ package.json | 2 +- src/main/ipc.ts | 3 +- .../src/pages/settings/AboutSettings.tsx | 8 ---- yarn.lock | 20 +++++++++- 5 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 .yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch diff --git a/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch b/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch new file mode 100644 index 0000000000..84de47f3c4 --- /dev/null +++ b/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch @@ -0,0 +1,38 @@ +diff --git a/out/MacUpdater.js b/out/MacUpdater.js +index 8f18dc5416c91835ded4e47f2358fba680c129ac..a3fb43c2450dc3484bf099b5ea79a362a3b372cc 100644 +--- a/out/MacUpdater.js ++++ b/out/MacUpdater.js +@@ -74,7 +74,7 @@ class MacUpdater extends AppUpdater_1.AppUpdater { + else { + files = files.filter(file => !isArm64(file)); + } +- const zipFileInfo = (0, Provider_1.findFile)(files, "zip", ["pkg", "dmg"]); ++ const zipFileInfo = (0, Provider_1.findFile)(files, "zip", ["pkg", "dmg"], false /*has been filtered by myself*/); + if (zipFileInfo == null) { + throw (0, builder_util_runtime_1.newError)(`ZIP file not provided: ${(0, builder_util_runtime_1.safeStringifyJson)(files)}`, "ERR_UPDATER_ZIP_FILE_NOT_FOUND"); + } +diff --git a/out/providers/Provider.js b/out/providers/Provider.js +index 9829dff7e95aa9baa0bfdf29f52e6f761c9b7243..6ecaade9e294c87c03bb42e77ff5463f2782cb3c 100644 +--- a/out/providers/Provider.js ++++ b/out/providers/Provider.js +@@ -61,11 +61,18 @@ class Provider { + } + } + exports.Provider = Provider; +-function findFile(files, extension, not) { ++function findFile(files, extension, not, filterByArch = true) { + if (files.length === 0) { + throw (0, builder_util_runtime_1.newError)("No files provided", "ERR_UPDATER_NO_FILES_PROVIDED"); + } +- const result = files.find(it => it.url.pathname.toLowerCase().endsWith(`.${extension.toLowerCase()}`)); ++ const result = files ++ .filter(file => { ++ if (!filterByArch) { ++ return true; ++ } ++ return (process.arch == "arm64") === (file.url.pathname.includes("arm64") || file.info.url.includes("arm64")); ++ }) ++ .find(it => it.url.pathname.toLowerCase().endsWith(`.${extension.toLowerCase()}`)); + if (result != null) { + return result; + } diff --git a/package.json b/package.json index 781a74ab14..f1c393148f 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "docx": "^9.0.2", "electron-log": "^5.1.5", "electron-store": "^8.2.0", - "electron-updater": "^6.3.9", + "electron-updater": "patch:electron-updater@npm%3A6.6.3#~/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch", "electron-window-state": "^5.0.3", "epub": "patch:epub@npm%3A1.3.0#~/.yarn/patches/epub-npm-1.3.0-8325494ffe.patch", "extract-zip": "^2.0.1", diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 72e5d02147..41a2a3bee9 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -178,8 +178,7 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) { // check for update ipcMain.handle(IpcChannel.App_CheckForUpdate, async () => { - // 在 Windows 上,如果架构是 arm64,则不检查更新 - if (isWin && (arch().includes('arm') || 'PORTABLE_EXECUTABLE_DIR' in process.env)) { + if (isWin && 'PORTABLE_EXECUTABLE_DIR' in process.env) { return { currentVersion: app.getVersion(), updateInfo: null diff --git a/src/renderer/src/pages/settings/AboutSettings.tsx b/src/renderer/src/pages/settings/AboutSettings.tsx index 3ada653f7f..42bb5690f3 100644 --- a/src/renderer/src/pages/settings/AboutSettings.tsx +++ b/src/renderer/src/pages/settings/AboutSettings.tsx @@ -1,7 +1,6 @@ import { GithubOutlined } from '@ant-design/icons' import IndicatorLight from '@renderer/components/IndicatorLight' import { HStack } from '@renderer/components/Layout' -import { isWindows } from '@renderer/config/constant' import { APP_NAME, AppLogo } from '@renderer/config/env' import { useTheme } from '@renderer/context/ThemeProvider' import { useMinappPopup } from '@renderer/hooks/useMinappPopup' @@ -34,13 +33,6 @@ const AboutSettings: FC = () => { const onCheckUpdate = debounce( async () => { - const { arch } = await window.api.getAppInfo() - - if (isWindows && arch.includes('arm')) { - window.open('https://cherry-ai.com/download', '_blank') - return - } - if (update.checking || update.downloading) { return } diff --git a/yarn.lock b/yarn.lock index defe4e1697..69cde4315f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4374,7 +4374,7 @@ __metadata: electron-icon-builder: "npm:^2.0.1" electron-log: "npm:^5.1.5" electron-store: "npm:^8.2.0" - electron-updater: "npm:^6.3.9" + electron-updater: "patch:electron-updater@npm%3A6.6.3#~/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch" electron-vite: "npm:^2.3.0" electron-window-state: "npm:^5.0.3" emittery: "npm:^1.0.3" @@ -7043,7 +7043,7 @@ __metadata: languageName: node linkType: hard -"electron-updater@npm:^6.3.9": +"electron-updater@npm:6.6.3": version: 6.6.3 resolution: "electron-updater@npm:6.6.3" dependencies: @@ -7059,6 +7059,22 @@ __metadata: languageName: node linkType: hard +"electron-updater@patch:electron-updater@npm%3A6.6.3#~/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch": + version: 6.6.3 + resolution: "electron-updater@patch:electron-updater@npm%3A6.6.3#~/.yarn/patches/electron-updater-npm-6.6.3-9269dbaf84.patch::version=6.6.3&hash=4a31aa" + dependencies: + builder-util-runtime: "npm:9.3.2" + fs-extra: "npm:^10.1.0" + js-yaml: "npm:^4.1.0" + lazy-val: "npm:^1.0.5" + lodash.escaperegexp: "npm:^4.1.2" + lodash.isequal: "npm:^4.5.0" + semver: "npm:^7.6.3" + tiny-typed-emitter: "npm:^2.1.0" + checksum: 10c0/6c9540bfaca6a9f4f73ce665f104d5954feb237950c59a73497b8e49b61820735276008c483eb5a7216b0b4c2fc4ca1a5474064645e5b52daa76b43661b3ced1 + languageName: node + linkType: hard + "electron-vite@npm:^2.3.0": version: 2.3.0 resolution: "electron-vite@npm:2.3.0"