修复托盘创建显示隐藏Bug

This commit is contained in:
lyswhut
2020-04-03 20:42:02 +08:00
parent 426c88c4ed
commit 76b3b3b23d
5 changed files with 15 additions and 17 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ global.lx_event.tray.on(TRAY_EVENT_NAME.destroy, () => {
let tray
function createTray() {
if (tray && !tray.isDestroyed() && global.appSetting.tray && global.appSetting.tray.isShow) return
if ((tray && !tray.isDestroyed()) || !global.appSetting.tray || !global.appSetting.tray.isShow) return
const iconPath = path.join(global.__static, 'images/tray', isWin ? '256x256.ico' : isMac ? '512x512.icns' : '512x512.png')
+6 -11
View File
@@ -1,17 +1,12 @@
// const { app } = require('electron')
const { mainOn } = require('../../common/ipc')
mainOn('changeTray', (event, params) => {
switch (params.action) {
case 'create':
global.lx_event.tray.create()
break
case 'destroy':
global.lx_event.tray.destroy()
break
default:
break
mainOn('changeTray', (event, setting) => {
global.appSetting.tray = setting
if (setting.isToTray) {
global.lx_event.tray.create()
} else {
global.lx_event.tray.destroy()
}
})
+6 -1
View File
@@ -1,5 +1,10 @@
module.exports = mainWindow => {
mainWindow.on('close', () => {
mainWindow.on('close', event => {
if (global.appSetting.tray.isToTray) {
event.preventDefault()
mainWindow.hide()
return
}
mainWindow.setProgressBar(-1)
})