修复mac下开启托盘时无法从dock退出的问题

pull/225/head
lyswhut 2020-04-30 23:41:45 +08:00
parent aed9889a2e
commit 7ed95ff523
3 changed files with 16 additions and 5 deletions

View File

@ -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() {

View File

@ -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()
})

View File

@ -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', () => {