feat: add auto-update functionality with settings UI

- Implement electron-updater integration with IPC handlers for update operations
- Add Pinia store for managing update state and user preferences
- Create settings UI with version display, update controls, and auto-update toggles
- Update IPC constants and preload API for update-related communication
- Refactor preload invoke methods to use async IPC consistently
- Add rounded corners to settings page layout for better visual consistency
This commit is contained in:
DEV_DSW
2026-04-09 15:15:23 +08:00
parent a8bfbff0e9
commit 1aa28a7808
10 changed files with 411 additions and 96 deletions

View File

@@ -46,6 +46,11 @@ var IPC_EVENTS = /* @__PURE__ */ ((IPC_EVENTS2) => {
IPC_EVENTS2["THEME_MODE_UPDATED"] = "theme-mode-updated";
IPC_EVENTS2["EXECUTE_SCRIPT"] = "execute-script";
IPC_EVENTS2["OPEN_CHANNEL"] = "open-channel";
IPC_EVENTS2["UPDATE_CHECK"] = "update:check";
IPC_EVENTS2["UPDATE_DOWNLOAD"] = "update:download";
IPC_EVENTS2["UPDATE_INSTALL"] = "update:install";
IPC_EVENTS2["UPDATE_VERSION"] = "update:version";
IPC_EVENTS2["UPDATE_STATUS_CHANGED"] = "update:status-changed";
return IPC_EVENTS2;
})(IPC_EVENTS || {});
const api = {
@@ -65,16 +70,10 @@ const api = {
},
// 通过 IPC 调用主进程
readFile: (filePath) => electron.ipcRenderer.invoke(IPC_EVENTS.READ_FILE, filePath),
// 步调用
invoke: (channel, ...args) => electron.ipcRenderer.sendSync(IPC_EVENTS.INVOKE, channel, ...args),
// 异步调用
invokeAsync: (channel, ...args) => {
try {
electron.ipcRenderer.invoke(IPC_EVENTS.INVOKE_ASYNC, channel, ...args);
} catch (error) {
throw error;
}
},
// 步调用(映射为 electron 的 invoke)
invoke: (channel, ...args) => electron.ipcRenderer.invoke(channel, ...args),
// 异步调用(为了兼容老代码)
invokeAsync: (channel, ...args) => electron.ipcRenderer.invoke(channel, ...args),
// 监听主进程消息
on: (event, callback) => {
const subscription = (_event, ...args) => callback(...args);