From 0b7d4bfb6a23cdc1ea032b9382c714bc5eaf5337 Mon Sep 17 00:00:00 2001 From: Gemini Wen Date: Tue, 8 Jul 2025 14:00:21 +0800 Subject: [PATCH] macOS: change window close behavior, like other macOS App (#999) --- src/main/index.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 66075554..9e064074 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -421,9 +421,6 @@ async function createWindow(first = true): Promise { store.set('fullscreen', mainWindow?.isFullScreen()); if (!exitFromTray && store.get('window_exit_to_tray')) { - if (isMacOS() && !forceQuit) { - exitFromTray = true; - } event.preventDefault(); mainWindow?.hide(); } @@ -432,8 +429,6 @@ async function createWindow(first = true): Promise { event.preventDefault(); saved = true; - getMainWindow()?.webContents.send('renderer-save-queue'); - ipcMain.once('player-save-queue', async (_event, data: Record) => { const queueLocation = join(app.getPath('userData'), 'queue'); const serialized = JSON.stringify(data); @@ -457,12 +452,19 @@ async function createWindow(first = true): Promise { } catch (error) { console.error('error saving queue state: ', error); } finally { - mainWindow?.close(); + if (!isMacOS()) { + mainWindow?.close(); + } if (forceQuit) { app.exit(); } } }); + getMainWindow()?.webContents.send('renderer-save-queue'); + } else { + if (forceQuit) { + app.exit(); + } } });