修复启用托盘后无法退出程序的问题
parent
2e84788d53
commit
be84bd27d3
|
@ -12,7 +12,14 @@ if (isMac) {
|
||||||
{ label: '显示其他', role: 'hideothers' },
|
{ label: '显示其他', role: 'hideothers' },
|
||||||
{ label: '显示全部', role: 'unhide' },
|
{ label: '显示全部', role: 'unhide' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: '退出', accelerator: 'Command+Q', click: () => app.quit() },
|
{
|
||||||
|
label: '退出',
|
||||||
|
accelerator: 'Command+Q',
|
||||||
|
click() {
|
||||||
|
global.isQuitting = true
|
||||||
|
app.quit()
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { Tray, Menu } = require('electron')
|
const { app, Tray, Menu } = require('electron')
|
||||||
const { isMac, isWin } = require('../../common/utils')
|
const { isMac, isWin } = require('../../common/utils')
|
||||||
const { tray: TRAY_EVENT_NAME } = require('../events/_name')
|
const { tray: TRAY_EVENT_NAME } = require('../events/_name')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
@ -21,7 +21,10 @@ function createTray() {
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
label: '退出',
|
label: '退出',
|
||||||
role: 'quit',
|
click() {
|
||||||
|
global.isQuitting = true
|
||||||
|
app.quit()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
tray.setToolTip('洛雪音乐助手')
|
tray.setToolTip('洛雪音乐助手')
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
global.isQuitting = false
|
||||||
|
|
||||||
module.exports = mainWindow => {
|
module.exports = mainWindow => {
|
||||||
mainWindow.on('close', event => {
|
mainWindow.on('close', event => {
|
||||||
if (global.appSetting.tray.isToTray) {
|
if (!global.isQuitting && global.appSetting.tray.isToTray) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
mainWindow.hide()
|
mainWindow.hide()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue