From cf901f3aa4a380357dcf46048dfbbac1e6f888e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=86=E5=95=A6=E5=A5=BD=E6=A2=A6?= <530353222@qq.com> Date: Tue, 7 Mar 2023 19:44:49 +0800 Subject: [PATCH] tray --- electron/addon/tray/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/electron/addon/tray/index.js b/electron/addon/tray/index.js index 27c6c4a..37d1b02 100644 --- a/electron/addon/tray/index.js +++ b/electron/addon/tray/index.js @@ -25,6 +25,7 @@ class TrayAddon { Log.info('[addon:tray] load'); + const app = this.app; const cfg = Conf.getValue('addons.tray'); const mainWindow = Electron.mainWindow; @@ -32,7 +33,6 @@ class TrayAddon { let iconPath = path.join(Ps.getHomeDir(), cfg.icon); // 托盘菜单功能列表 - const self = this; let trayMenuTemplate = [ { label: '显示', @@ -43,14 +43,14 @@ class TrayAddon { { label: '退出', click: function () { - self.app.appQuit(); + app.appQuit(); } } ] // 点击关闭,最小化到托盘 mainWindow.on('close', (event) => { - const extraObj = this.app.electron.extra; + const extraObj = Electron.extra; if (extraObj.closeWindow == true) { return; } @@ -60,7 +60,7 @@ class TrayAddon { // 实例化托盘 this.tray = new Tray(iconPath); - this.tray.setToolTip(this.cfg.title); + this.tray.setToolTip(cfg.title); const contextMenu = Menu.buildFromTemplate(trayMenuTemplate); this.tray.setContextMenu(contextMenu); }