From afc81b63081af2d805214a96ae7c43a13dc126b6 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 1 May 2020 18:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=89=98=E7=9B=98=E6=8C=82=E5=88=B0?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/modules/tray.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/modules/tray.js b/src/main/modules/tray.js index c6589ed7..84084288 100644 --- a/src/main/modules/tray.js +++ b/src/main/modules/tray.js @@ -9,19 +9,18 @@ global.lx_event.tray.on(TRAY_EVENT_NAME.destroy, () => { destroyTray() }) -let tray const createTray = () => { - if ((tray && !tray.isDestroyed()) || !global.appSetting.tray || !global.appSetting.tray.isShow) return + if ((global.tray && !global.tray.isDestroyed()) || !global.appSetting.tray || !global.appSetting.tray.isShow) return const iconPath = path.join(global.__static, 'images/tray', isWin ? 'trayTemplate.ico' : 'trayTemplate.png') // 托盘 - tray = new Tray(iconPath) + global.tray = new Tray(iconPath) - tray.setToolTip('洛雪音乐助手') - if (isWin) createMenu(tray) - tray.setIgnoreDoubleClickEvents(true) - tray.on('click', () => { + global.tray.setToolTip('洛雪音乐助手') + if (isWin) createMenu(global.tray) + global.tray.setIgnoreDoubleClickEvents(true) + global.tray.on('click', () => { const mainWindow = global.mainWindow if (!mainWindow) return mainWindow.isVisible() @@ -31,9 +30,9 @@ const createTray = () => { } const destroyTray = () => { - if (!tray) return - tray.destroy() - tray = null + if (!global.tray) return + global.tray.destroy() + global.tray = null } const createMenu = tray => {