Hide the dock icon on macOS when no windows are open

https://github.com/samuelthomas2774/nxapi/issues/18
This commit is contained in:
Samuel Elliott 2022-08-24 18:39:52 +01:00
parent a6b8dc33e8
commit ce6272318e
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6

View File

@ -120,9 +120,18 @@ export async function init() {
if (BrowserWindow.getAllWindows().length === 0) appinstance.showMainWindow();
});
app.on('browser-window-created', () => {
// Show the dock icon when any windows are open
app.dock?.show();
});
app.on('window-all-closed', () => {
// Listen to the window-all-closed event to prevent Electron quitting the app
// https://www.electronjs.org/docs/latest/api/app#event-window-all-closed
// Hide the dock icon when no windows are open
// https://github.com/samuelthomas2774/nxapi/issues/18
app.dock?.hide();
});
debug('App started');