修复mac下开启托盘时无法从dock退出的问题
parent
aed9889a2e
commit
7ed95ff523
|
@ -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() {
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
Loading…
Reference in New Issue