Browse Source

MacOS exit to tray (#268)

* respect MacOS menu quit

* exit to tray default for MacOS

* fix lint issues
master
zackslash 3 years ago
committed by GitHub
parent
commit
ceea806781
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/components/shared/setDefaultSettings.ts
  2. 8
      src/main.dev.js
  3. 2
      src/menu.ts

6
src/components/shared/setDefaultSettings.ts

@ -77,7 +77,11 @@ const setDefaultSettings = (force: boolean) => {
} }
if (force || !settings.hasSync('exitToTray')) { if (force || !settings.hasSync('exitToTray')) {
settings.setSync('exitToTray', false); let defaultExitToTray = false;
if (isMacOS()) {
defaultExitToTray = true;
}
settings.setSync('exitToTray', defaultExitToTray);
} }
if (force || !settings.hasSync('showDebugWindow')) { if (force || !settings.hasSync('showDebugWindow')) {

8
src/main.dev.js

@ -49,6 +49,7 @@ replayActionMain(store);
let mainWindow = null; let mainWindow = null;
let tray = null; let tray = null;
let exitFromTray = false; let exitFromTray = false;
let forceQuit = false;
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
const sourceMapSupport = require('source-map-support'); const sourceMapSupport = require('source-map-support');
@ -538,6 +539,9 @@ const createWindow = async () => {
event.preventDefault(); event.preventDefault();
mainWindow.hide(); mainWindow.hide();
} }
if (forceQuit) {
app.exit();
}
}); });
if (isWindows()) { if (isWindows()) {
@ -586,6 +590,10 @@ const createWindow = async () => {
height: window.height, height: window.height,
}); });
}); });
app.on('before-quit', () => {
forceQuit = true;
});
} }
mainWindow.once('maximize', () => { mainWindow.once('maximize', () => {

2
src/menu.ts

@ -68,7 +68,7 @@ export default class MenuBuilder {
label: 'Quit', label: 'Quit',
accelerator: 'Command+Q', accelerator: 'Command+Q',
click: () => { click: () => {
app.quit(); app.exit();
}, },
}, },
], ],

Loading…
Cancel
Save