Handle shutdown event on Mac with minimizeOnClose to prevent shutdown interrupt

This commit is contained in:
Nick Denry 2020-05-28 00:39:33 +03:00
parent d06000103f
commit e8b17a0003
1 changed files with 16 additions and 1 deletions

17
main.js
View File

@ -10,10 +10,13 @@ const trayService = require(__dirname+'/modules/tray-service')
const menuService = require(__dirname+'/modules/menu-service')
const settingsService = require(__dirname+'/modules/settings-service')
const isMac = process.platform === 'darwin'
const isWin = process.platform === 'win32'
function initApp() {
createWindow()
// Set Windows platform notifications
if (process.platform === 'win32') {
if (isWin) {
app.setAppUserModelId("com.denry.chimeverse")
}
}
@ -77,6 +80,18 @@ function createWindow () {
})
}
// Handle shutdown event on Mac with minimizeOnClose
// to prevent shutdown interrupt
if (isMac) {
if (minimizeOnClose) {
const { powerMonitor } = require('electron')
powerMonitor.on('shutdown', () => {
app.isQuitting = true
app.quit()
})
}
}
// Save window size
if (preserveWindowSize) {
mainWindow.on('resize', (e) => {