mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 15:19:03 +08:00
feat: 支持忽略更新
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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: ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user