fix: 发布 2.3.1 更新安装修复

This commit is contained in:
ILoveBingLu
2026-04-02 04:47:30 +08:00
parent 269375fde6
commit 0da479bed7
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -70,6 +70,7 @@ let logService: LogService | null = null
// 系统托盘实例
let tray: Tray | null = null
let isInstallingUpdate = false
// 聊天窗口实例
let chatWindow: BrowserWindow | null = null
@@ -221,6 +222,11 @@ function createWindow() {
return
}
if (isInstallingUpdate) {
app.isQuitting = true
return
}
// 如果是真正退出应用,不阻止
if (app.isQuitting) {
return
@@ -1325,6 +1331,7 @@ function registerIpcHandlers() {
ipcMain.handle('app:downloadAndInstall', async (event) => {
const win = BrowserWindow.fromWebContents(event.sender)
isInstallingUpdate = true
// 监听下载进度
autoUpdater.on('download-progress', (progress) => {
@@ -1333,12 +1340,14 @@ function registerIpcHandlers() {
// 下载完成后自动安装
autoUpdater.on('update-downloaded', () => {
app.isQuitting = true
autoUpdater.quitAndInstall(false, true)
})
try {
await autoUpdater.downloadUpdate()
} catch (error) {
isInstallingUpdate = false
console.error('下载更新失败:', error)
throw error
}