mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-18 20:17:09 +08:00
fix(desktop): auto-update install now actually replaces the app
This commit is contained in:
@@ -253,7 +253,14 @@ function setupIPC() {
|
||||
setUpdateLanguage(lang)
|
||||
startDownload()
|
||||
})
|
||||
ipcMain.handle('update-install', () => quitAndInstall())
|
||||
ipcMain.handle('update-install', () => {
|
||||
// Let the window actually close so the app can fully quit — otherwise the
|
||||
// close-to-tray handler preventDefault()s it, the process stays alive, and
|
||||
// Squirrel.Mac can't swap the app bundle (the update silently no-ops and
|
||||
// relaunching still shows the old version).
|
||||
isQuitting = true
|
||||
quitAndInstall()
|
||||
})
|
||||
|
||||
// Synchronous OS locale lookup (e.g. "zh-CN", "en-US"). Used by the renderer
|
||||
// to pick a sensible default UI language on first run before any paint.
|
||||
|
||||
@@ -229,6 +229,16 @@ function attemptDownload(): void {
|
||||
export function quitAndInstall(): void {
|
||||
if (!app.isPackaged) return
|
||||
log('quitAndInstall: relaunching to install update')
|
||||
// isSilent=false (show installer), isForceRunAfter=true (relaunch after).
|
||||
autoUpdater.quitAndInstall(false, true)
|
||||
// isSilent MUST be true on Windows: our NSIS installer is an "assisted"
|
||||
// installer (oneClick:false + allowToChangeInstallationDirectory), so a
|
||||
// non-silent update re-shows the install-dir / install-mode wizard instead of
|
||||
// updating in place. Silent skips the wizard and updates directly. macOS
|
||||
// (Squirrel.Mac) ignores isSilent, so false there is fine.
|
||||
// isForceRunAfter=true relaunches the app once the install finishes.
|
||||
// Drop window-all-closed handlers first: with an assisted NSIS installer a
|
||||
// lingering handler can keep the process alive and stop the installer from
|
||||
// replacing files / relaunching (a documented electron-updater gotcha).
|
||||
app.removeAllListeners('window-all-closed')
|
||||
const isSilent = process.platform === 'win32'
|
||||
autoUpdater.quitAndInstall(isSilent, true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user