feat: 支持客户端更新

This commit is contained in:
digua
2025-12-17 20:56:56 +08:00
parent 1e08294472
commit 41fd2b2eca
5 changed files with 155 additions and 23 deletions
+13
View File
@@ -6,6 +6,7 @@ import { ipcMain, app, dialog, clipboard, shell } from 'electron'
import { autoUpdater } from 'electron-updater'
import * as fs from 'fs/promises'
import type { IpcContext } from './types'
import { simulateUpdateDialog } from '../update'
/**
* 注册窗口和文件系统操作 IPC 处理器
@@ -53,11 +54,23 @@ export function registerWindowHandlers(ctx: IpcContext): void {
win.webContents.openDevTools()
})
// ==================== 应用信息 ====================
ipcMain.handle('app:getVersion', () => {
return app.getVersion()
})
// ==================== 更新检查 ====================
ipcMain.on('check-update', () => {
autoUpdater.checkForUpdates()
})
// 模拟更新弹窗(仅开发模式使用)
ipcMain.on('simulate-update', () => {
if (!app.isPackaged) {
simulateUpdateDialog(win)
}
})
// ==================== 通用工具 ====================
ipcMain.handle('show-message', (event, args) => {
event.sender.send('show-message', args)