Skip to content

Commit 3935152

Browse files
committed
Fix close window on darwin
1 parent d65f568 commit 3935152

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

public/electron.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ const createWindow = () => {
4747
mainWindow.webContents.openDevTools();
4848
}
4949

50-
mainWindow.on('closed', () => (mainWindow = null));
50+
mainWindow.on('closed', () => mainWindow = null);
51+
52+
mainWindow.on('close', (event) => {
53+
if (app.quitting) {
54+
mainWindow = null;
55+
} else {
56+
event.preventDefault();
57+
mainWindow.hide();
58+
}
59+
});
5160

5261
destroyStream = registerEvents(mainWindow);
5362
};
@@ -65,5 +74,9 @@ app.on('window-all-closed', () => {
6574
app.on('activate', () => {
6675
if (!mainWindow) {
6776
createWindow();
77+
} else {
78+
mainWindow.show();
6879
}
6980
});
81+
82+
app.on('before-quit', () => app.quitting = true);

0 commit comments

Comments
 (0)