修复mac下开启托盘时无法从dock退出的问题
parent
aed9889a2e
commit
7ed95ff523
|
@ -36,6 +36,13 @@ function createTray() {
|
||||||
? mainWindow.focus()
|
? mainWindow.focus()
|
||||||
: mainWindow.show()
|
: mainWindow.show()
|
||||||
})
|
})
|
||||||
|
tray.on('double-click', () => {
|
||||||
|
const mainWindow = global.mainWindow
|
||||||
|
if (!mainWindow) return
|
||||||
|
mainWindow.isVisible()
|
||||||
|
? mainWindow.focus()
|
||||||
|
: mainWindow.show()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroyTray() {
|
function destroyTray() {
|
||||||
|
|
|
@ -13,6 +13,6 @@ mainOn('max', event => {
|
||||||
})
|
})
|
||||||
mainOn('close', (event, isForce) => {
|
mainOn('close', (event, isForce) => {
|
||||||
if (isForce) return app.exit(0)
|
if (isForce) return app.exit(0)
|
||||||
|
global.isTrafficLightClose = true
|
||||||
if (global.mainWindow) global.mainWindow.close()
|
if (global.mainWindow) global.mainWindow.close()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
const { isMac } = require('../../common/utils')
|
||||||
global.isQuitting = false
|
global.isQuitting = false
|
||||||
|
global.isTrafficLightClose = false // 是否点击软件上的关闭按钮关闭
|
||||||
|
|
||||||
module.exports = mainWindow => {
|
module.exports = mainWindow => {
|
||||||
mainWindow.on('close', event => {
|
mainWindow.on('close', event => {
|
||||||
if (!global.isQuitting && global.appSetting.tray.isToTray) {
|
if (global.isQuitting || !global.appSetting.tray.isToTray || (isMac && !global.isTrafficLightClose)) {
|
||||||
event.preventDefault()
|
mainWindow.setProgressBar(-1)
|
||||||
mainWindow.hide()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mainWindow.setProgressBar(-1)
|
|
||||||
|
if (global.isTrafficLightClose) global.isTrafficLightClose = false
|
||||||
|
event.preventDefault()
|
||||||
|
mainWindow.hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.on('closed', () => {
|
mainWindow.on('closed', () => {
|
||||||
|
|
Loading…
Reference in New Issue