diff --git a/src/main/modules/tray.js b/src/main/modules/tray.js index 6f496f72..924182c0 100644 --- a/src/main/modules/tray.js +++ b/src/main/modules/tray.js @@ -36,6 +36,13 @@ function createTray() { ? mainWindow.focus() : mainWindow.show() }) + tray.on('double-click', () => { + const mainWindow = global.mainWindow + if (!mainWindow) return + mainWindow.isVisible() + ? mainWindow.focus() + : mainWindow.show() + }) } function destroyTray() { diff --git a/src/main/rendererEvents/trafficLight.js b/src/main/rendererEvents/trafficLight.js index 3e3805d9..9447a932 100644 --- a/src/main/rendererEvents/trafficLight.js +++ b/src/main/rendererEvents/trafficLight.js @@ -13,6 +13,6 @@ mainOn('max', event => { }) mainOn('close', (event, isForce) => { if (isForce) return app.exit(0) - + global.isTrafficLightClose = true if (global.mainWindow) global.mainWindow.close() }) diff --git a/src/main/rendererEvents/winEvent.js b/src/main/rendererEvents/winEvent.js index 7e87064a..5bbd0139 100644 --- a/src/main/rendererEvents/winEvent.js +++ b/src/main/rendererEvents/winEvent.js @@ -1,13 +1,17 @@ +const { isMac } = require('../../common/utils') global.isQuitting = false +global.isTrafficLightClose = false // 是否点击软件上的关闭按钮关闭 module.exports = mainWindow => { mainWindow.on('close', event => { - if (!global.isQuitting && global.appSetting.tray.isToTray) { - event.preventDefault() - mainWindow.hide() + if (global.isQuitting || !global.appSetting.tray.isToTray || (isMac && !global.isTrafficLightClose)) { + mainWindow.setProgressBar(-1) return } - mainWindow.setProgressBar(-1) + + if (global.isTrafficLightClose) global.isTrafficLightClose = false + event.preventDefault() + mainWindow.hide() }) mainWindow.on('closed', () => {