Skip to content

Commit

Permalink
fix(desktop): ensure app fully exits on window close
Browse files Browse the repository at this point in the history
  • Loading branch information
mayneyao committed Oct 23, 2024
1 parent 5ab91d2 commit e342143
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,26 @@ function createTray() {
}
}

function destroyTray() {
if (tray) {
tray.destroy();
tray = null;
}
}

app.whenReady().then(() => {
win = createWindow()
createTray();

win.on('close', (event) => {
if (!forceQuit) {
event.preventDefault();
if (process.platform === 'darwin') {
event.preventDefault();
win?.hide();
} else {
win?.minimize();
forceQuit = true;
destroyTray();
app.quit();
}
}
});
Expand All @@ -178,5 +187,6 @@ app.on('activate', () => {

ipcMain.handle('quit-app', () => {
forceQuit = true;
destroyTray();
app.quit();
});

0 comments on commit e342143

Please sign in to comment.