feat(ipc): add App_Quit channel and update related handlers

- Introduced a new IPC channel for quitting the application.
- Updated ipc.ts to handle the App_Quit channel, allowing the app to quit when invoked.
- Added corresponding quit method in the preload API for client-side access.
- Fixed a minor URL check in WindowService to ensure proper navigation handling.
This commit is contained in:
kangfenmao 2025-09-22 20:20:14 +08:00
parent a847b74c32
commit 183b46be9e
4 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,7 @@ export enum IpcChannel {
App_ShowUpdateDialog = 'app:show-update-dialog',
App_CheckForUpdate = 'app:check-for-update',
App_Reload = 'app:reload',
App_Quit = 'app:quit',
App_Info = 'app:info',
App_Proxy = 'app:proxy',
App_SetLaunchToTray = 'app:set-launch-to-tray',

View File

@ -126,6 +126,7 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
})
ipcMain.handle(IpcChannel.App_Reload, () => mainWindow.reload())
ipcMain.handle(IpcChannel.App_Quit, () => app.quit())
ipcMain.handle(IpcChannel.Open_Website, (_, url: string) => shell.openExternal(url))
// Update

View File

@ -256,7 +256,7 @@ export class WindowService {
private setupWebContentsHandlers(mainWindow: BrowserWindow) {
mainWindow.webContents.on('will-navigate', (event, url) => {
if (url.includes('localhost:5173')) {
if (url.includes('localhost:517')) {
return
}

View File

@ -47,6 +47,7 @@ const api = {
getDiskInfo: (directoryPath: string): Promise<{ free: number; size: number } | null> =>
ipcRenderer.invoke(IpcChannel.App_GetDiskInfo, directoryPath),
reload: () => ipcRenderer.invoke(IpcChannel.App_Reload),
quit: () => ipcRenderer.invoke(IpcChannel.App_Quit),
setProxy: (proxy: string | undefined, bypassRules?: string) =>
ipcRenderer.invoke(IpcChannel.App_Proxy, proxy, bypassRules),
checkForUpdate: () => ipcRenderer.invoke(IpcChannel.App_CheckForUpdate),