修复托盘创建显示隐藏Bug
parent
426c88c4ed
commit
76b3b3b23d
|
@ -11,7 +11,7 @@ global.lx_event.tray.on(TRAY_EVENT_NAME.destroy, () => {
|
||||||
|
|
||||||
let tray
|
let tray
|
||||||
function createTray() {
|
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')
|
const iconPath = path.join(global.__static, 'images/tray', isWin ? '256x256.ico' : isMac ? '512x512.icns' : '512x512.png')
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
// const { app } = require('electron')
|
// const { app } = require('electron')
|
||||||
const { mainOn } = require('../../common/ipc')
|
const { mainOn } = require('../../common/ipc')
|
||||||
|
|
||||||
mainOn('changeTray', (event, params) => {
|
mainOn('changeTray', (event, setting) => {
|
||||||
switch (params.action) {
|
global.appSetting.tray = setting
|
||||||
case 'create':
|
if (setting.isToTray) {
|
||||||
global.lx_event.tray.create()
|
global.lx_event.tray.create()
|
||||||
break
|
} else {
|
||||||
case 'destroy':
|
|
||||||
global.lx_event.tray.destroy()
|
global.lx_event.tray.destroy()
|
||||||
break
|
|
||||||
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
module.exports = mainWindow => {
|
module.exports = mainWindow => {
|
||||||
mainWindow.on('close', () => {
|
mainWindow.on('close', event => {
|
||||||
|
if (global.appSetting.tray.isToTray) {
|
||||||
|
event.preventDefault()
|
||||||
|
mainWindow.hide()
|
||||||
|
return
|
||||||
|
}
|
||||||
mainWindow.setProgressBar(-1)
|
mainWindow.setProgressBar(-1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,7 @@ export default {
|
||||||
rendererSend('max')
|
rendererSend('max')
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
rendererSend('close', {
|
rendererSend('close')
|
||||||
isToTray: this.setting.tray.isToTray,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -628,7 +628,7 @@ export default {
|
||||||
},
|
},
|
||||||
handleToTrayChange(isToTray) {
|
handleToTrayChange(isToTray) {
|
||||||
this.current_setting.tray.isShow = isToTray
|
this.current_setting.tray.isShow = isToTray
|
||||||
rendererSend('changeTray', { action: isToTray ? 'create' : 'destroy' })
|
rendererSend('changeTray', this.current_setting.tray)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue