From 06c020d9ca9b275ad833d779bb8f62c13d9510fb Mon Sep 17 00:00:00 2001 From: cc <98377878+hicccc77@users.noreply.github.com> Date: Sat, 18 Apr 2026 15:29:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E6=94=AF=E6=8C=81mac?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-daily-fixed.yml | 2 +- .github/workflows/preview-nightly-main.yml | 2 +- .github/workflows/release.yml | 4 ++-- electron/main.ts | 14 +++++++++++--- src/pages/SettingsPage.tsx | 10 ++++++++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dev-daily-fixed.yml b/.github/workflows/dev-daily-fixed.yml index e47ffbd..d90ea6b 100644 --- a/.github/workflows/dev-daily-fixed.yml +++ b/.github/workflows/dev-daily-fixed.yml @@ -107,7 +107,7 @@ jobs: run: | export ELECTRON_BUILDER_BINARIES_MIRROR="https://github.com/electron-userland/electron-builder-binaries/releases/download/" echo "Using ELECTRON_BUILDER_BINARIES_MIRROR=$ELECTRON_BUILDER_BINARIES_MIRROR" - npx electron-builder --mac dmg --arm64 --publish never '--config.publish.channel=dev' '--config.artifactName=${productName}-dev-arm64.${ext}' + npx electron-builder --mac dmg zip --arm64 --publish never '--config.publish.channel=dev' '--config.artifactName=${productName}-dev-arm64.${ext}' - name: Upload macOS arm64 assets to fixed release env: diff --git a/.github/workflows/preview-nightly-main.yml b/.github/workflows/preview-nightly-main.yml index aba5cbb..94ad390 100644 --- a/.github/workflows/preview-nightly-main.yml +++ b/.github/workflows/preview-nightly-main.yml @@ -136,7 +136,7 @@ jobs: run: | export ELECTRON_BUILDER_BINARIES_MIRROR="https://github.com/electron-userland/electron-builder-binaries/releases/download/" echo "Using ELECTRON_BUILDER_BINARIES_MIRROR=$ELECTRON_BUILDER_BINARIES_MIRROR" - npx electron-builder --mac dmg --arm64 --publish never '--config.publish.channel=preview' '--config.artifactName=${productName}-preview-arm64.${ext}' + npx electron-builder --mac dmg zip --arm64 --publish never '--config.publish.channel=preview' '--config.artifactName=${productName}-preview-arm64.${ext}' - name: Upload macOS arm64 assets to fixed preview release env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7092e50..a257720 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: npx tsc npx vite build - - name: Package and Publish macOS arm64 (unsigned DMG) + - name: Package and Publish macOS arm64 (unsigned DMG + ZIP) env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CSC_IDENTITY_AUTO_DISCOVERY: "false" @@ -51,7 +51,7 @@ jobs: run: | export ELECTRON_BUILDER_BINARIES_MIRROR="https://github.com/electron-userland/electron-builder-binaries/releases/download/" echo "Using ELECTRON_BUILDER_BINARIES_MIRROR=$ELECTRON_BUILDER_BINARIES_MIRROR" - npx electron-builder --mac dmg --arm64 --publish always + npx electron-builder --mac dmg zip --arm64 --publish always - name: Inject minimumVersion into latest yml env: diff --git a/electron/main.ts b/electron/main.ts index 7e4d381..4d11ca1 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1891,9 +1891,17 @@ function registerIpcHandlers() { downloadedHandler = null } - // 统一错误提示格式,避免出现 [object Object] 的 JSON 字符串 - const errorMessage = error.message || (typeof error === 'string' ? error : JSON.stringify(error)) - throw new Error(errorMessage) + const errorCode = typeof error?.code === 'string' ? error.code : '' + const rawErrorMessage = + typeof error?.message === 'string' + ? error.message + : (typeof error === 'string' ? error : JSON.stringify(error)) + + if (errorCode === 'ERR_UPDATER_ZIP_FILE_NOT_FOUND' || /ZIP file not provided/i.test(rawErrorMessage)) { + throw new Error('当前发布版本缺少 macOS 自动更新所需的 ZIP 包,请联系开发者重新发布该版本') + } + + throw new Error(rawErrorMessage || '下载更新失败,请稍后重试') } }) diff --git a/src/pages/SettingsPage.tsx b/src/pages/SettingsPage.tsx index 42d6079..851d8d1 100644 --- a/src/pages/SettingsPage.tsx +++ b/src/pages/SettingsPage.tsx @@ -652,6 +652,12 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) { void refreshWhisperStatus(whisperModelDir) }, [whisperModelDir]) + const getErrorMessage = (error: any): string => { + const raw = typeof error?.message === 'string' ? error.message : String(error ?? '') + const normalized = raw.replace(/^Error:\s*/i, '').trim() + return normalized || '未知错误' + } + const handleCheckUpdate = async () => { if (isCheckingUpdate) return setIsCheckingUpdate(true) @@ -666,7 +672,7 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) { showMessage('当前已是最新版', true) } } catch (e: any) { - showMessage(`检查更新失败: ${e}`, false) + showMessage(`检查更新失败: ${getErrorMessage(e)}`, false) } finally { setIsCheckingUpdate(false) } @@ -681,7 +687,7 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) { showMessage('正在下载更新...', true) await window.electronAPI.app.downloadAndInstall() } catch (e: any) { - showMessage(`更新失败: ${e}`, false) + showMessage(`更新失败: ${getErrorMessage(e)}`, false) setIsDownloading(false) } }