From 5615d83f04f2957e57763a3c90ba589d984a4a1a Mon Sep 17 00:00:00 2001 From: cc <98377878+hicccc77@users.noreply.github.com> Date: Sat, 4 Apr 2026 10:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- electron/main.ts | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 95745fb..99f4414 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,5 @@ resources/wx_send pnpm-lock.yaml /pnpm-workspace.yaml wechat-research-site -.codex \ No newline at end of file +.codex +weflow-web-offical \ No newline at end of file diff --git a/electron/main.ts b/electron/main.ts index b2a93e5..080f247 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -136,6 +136,7 @@ const shouldOfferUpdateForTrack = (latestVersion: string, currentVersion: string } let lastAppliedUpdaterChannel: string | null = null +let lastAppliedUpdaterFeedUrl: string | null = null const resetUpdaterProviderCache = () => { const updater = autoUpdater as any // electron-updater 会缓存 provider;切换 channel 后需清理缓存,避免仍请求旧通道 @@ -146,23 +147,41 @@ const resetUpdaterProviderCache = () => { } } +const getUpdaterFeedUrlByTrack = (track: 'stable' | 'preview' | 'dev'): string => { + const repoBase = 'https://github.com/hicccc77/WeFlow/releases' + if (track === 'stable') return `${repoBase}/latest/download` + if (track === 'preview') return `${repoBase}/download/nightly-preview` + return `${repoBase}/download/nightly-dev` +} + const applyAutoUpdateChannel = (reason: 'startup' | 'settings' = 'startup') => { const track = getEffectiveUpdateTrack() const currentTrack = inferUpdateTrackFromVersion(appVersion) const baseUpdateChannel = track === 'stable' ? 'latest' : track + const nextFeedUrl = getUpdaterFeedUrlByTrack(track) const nextUpdaterChannel = process.platform === 'win32' && process.arch === 'arm64' ? `${baseUpdateChannel}-arm64` : baseUpdateChannel - if (lastAppliedUpdaterChannel && lastAppliedUpdaterChannel !== nextUpdaterChannel) { + if ( + (lastAppliedUpdaterChannel && lastAppliedUpdaterChannel !== nextUpdaterChannel) || + (lastAppliedUpdaterFeedUrl && lastAppliedUpdaterFeedUrl !== nextFeedUrl) + ) { resetUpdaterProviderCache() } autoUpdater.allowPrerelease = track !== 'stable' // 只要用户当前选择的目标通道与当前安装版本所属通道不同,就允许跨通道更新(含降级) autoUpdater.allowDowngrade = track !== currentTrack + // 统一走 generic feed,确保 preview/dev 命中各自固定发布页,不受 GitHub provider 的 prerelease 选择影响。 + autoUpdater.setFeedURL({ + provider: 'generic', + url: nextFeedUrl, + channel: nextUpdaterChannel + }) autoUpdater.channel = nextUpdaterChannel lastAppliedUpdaterChannel = nextUpdaterChannel - console.log(`[Update](${reason}) 当前版本 ${appVersion},当前轨道: ${currentTrack},渠道偏好: ${track},更新通道: ${autoUpdater.channel},allowDowngrade=${autoUpdater.allowDowngrade}`) + lastAppliedUpdaterFeedUrl = nextFeedUrl + console.log(`[Update](${reason}) 当前版本 ${appVersion},当前轨道: ${currentTrack},渠道偏好: ${track},更新通道: ${autoUpdater.channel},feed=${nextFeedUrl},allowDowngrade=${autoUpdater.allowDowngrade}`) } applyAutoUpdateChannel('startup')