feat: 支持忽略更新

This commit is contained in:
cc
2026-02-01 20:50:01 +08:00
committed by xuncha
parent cb37f534ac
commit 123a088a39
9 changed files with 96 additions and 2 deletions

View File

@@ -552,6 +552,11 @@ function registerIpcHandlers() {
}
})
ipcMain.handle('app:ignoreUpdate', async (_, version: string) => {
configService?.set('ignoredUpdateVersion', version)
return { success: true }
})
// 窗口控制
ipcMain.on('window:minimize', (event) => {
BrowserWindow.fromWebContents(event.sender)?.minimize()
@@ -1159,7 +1164,16 @@ function checkForUpdatesOnStartup() {
if (result && result.updateInfo) {
const currentVersion = app.getVersion()
const latestVersion = result.updateInfo.version
// 检查是否有新版本
if (latestVersion !== currentVersion && mainWindow) {
// 检查该版本是否被用户忽略
const ignoredVersion = configService?.get('ignoredUpdateVersion')
if (ignoredVersion === latestVersion) {
console.log(`版本 ${latestVersion} 已被用户忽略,跳过更新提示`)
return
}
// 通知渲染进程有新版本
mainWindow.webContents.send('app:updateAvailable', {
version: latestVersion,

View File

@@ -34,6 +34,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
getVersion: () => ipcRenderer.invoke('app:getVersion'),
checkForUpdates: () => ipcRenderer.invoke('app:checkForUpdates'),
downloadAndInstall: () => ipcRenderer.invoke('app:downloadAndInstall'),
ignoreUpdate: (version: string) => ipcRenderer.invoke('app:ignoreUpdate', version),
onDownloadProgress: (callback: (progress: any) => void) => {
ipcRenderer.on('app:downloadProgress', (_, progress) => callback(progress))
return () => ipcRenderer.removeAllListeners('app:downloadProgress')

View File

@@ -33,6 +33,9 @@ interface ConfigSchema {
authEnabled: boolean
authPassword: string // SHA-256 hash
authUseHello: boolean
// 更新相关
ignoredUpdateVersion: string
}
export class ConfigService {
@@ -67,7 +70,9 @@ export class ConfigService {
authEnabled: false,
authPassword: '',
authUseHello: false
authUseHello: false,
ignoredUpdateVersion: ''
}
})
}