[enhancement]: Start minimized (#522)

* [enhancement]: support starting minimized

* show window when dock clicked macos
This commit is contained in:
Kendall Garner 2024-02-23 16:31:17 +00:00 committed by GitHub
parent 77fa723cf8
commit 5caf0d439f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 5 deletions

View file

@ -206,7 +206,7 @@ const createTray = () => {
tray.setContextMenu(contextMenu);
};
const createWindow = async () => {
const createWindow = async (first = true) => {
if (isDevelopment) {
await installExtensions();
}
@ -350,13 +350,14 @@ const createWindow = async () => {
mainWindow.loadURL(resolveHtmlPath('index.html'));
const startWindowMinimized = store.get('window_start_minimized', false) as boolean;
mainWindow.on('ready-to-show', () => {
if (!mainWindow) {
throw new Error('"mainWindow" is not defined');
}
if (process.env.START_MINIMIZED) {
mainWindow.minimize();
} else {
if (!first || !startWindowMinimized) {
mainWindow.show();
createWinThumbarButtons();
}
@ -608,7 +609,11 @@ if (!singleInstance) {
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
if (mainWindow === null) createWindow(false);
else if (!mainWindow.isVisible()) {
mainWindow.show();
createWinThumbarButtons();
}
});
})
.catch(console.log);