From b9b9eb9c022860602e905fbd4b7945f8f4734068 Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Thu, 19 Feb 2026 01:50:31 +0800 Subject: [PATCH] feat(electron): implement minimize to tray on close for Windows (#106) --- electron/main/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 51af62855..83f8dc9db 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -20,6 +20,7 @@ app.disableHardwareAcceleration(); // Global references let mainWindow: BrowserWindow | null = null; +let isQuitting = false; const gatewayManager = new GatewayManager(); const clawHubService = new ClawHubService(); @@ -164,7 +165,14 @@ async function initialize(): Promise { // Note: Auto-check for updates is driven by the renderer (update store init) // so it respects the user's "Auto-check for updates" setting. - // Handle window close + // Windows: minimize to tray on close instead of quitting + mainWindow.on('close', (event) => { + if (process.platform === 'win32' && !isQuitting) { + event.preventDefault(); + mainWindow?.hide(); + } + }); + mainWindow.on('closed', () => { mainWindow = null; }); @@ -200,6 +208,7 @@ app.on('window-all-closed', () => { }); app.on('before-quit', async () => { + isQuitting = true; await gatewayManager.stop(); });