From 7ed95ff523ca5c1fcfe605f94e0a6d55e712c7b6 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 30 Apr 2020 23:41:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmac=E4=B8=8B=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E6=89=98=E7=9B=98=E6=97=B6=E6=97=A0=E6=B3=95=E4=BB=8E?= =?UTF-8?q?dock=E9=80=80=E5=87=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/modules/tray.js | 7 +++++++ src/main/rendererEvents/trafficLight.js | 2 +- src/main/rendererEvents/winEvent.js | 12 ++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) 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', () => {