From 4d621c75215ea6ac9afbc7f83627edf3044dfb6f Mon Sep 17 00:00:00 2001 From: layyback <505187749@qq.com> Date: Tue, 22 Mar 2022 14:53:46 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix:=E4=BF=AE=E5=A4=8DTray=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=94=A4=E8=B5=B7=E7=83=AD=E9=94=AE=E4=B8=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/common/tray.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/common/tray.ts b/src/main/common/tray.ts index a651f0d..743447a 100644 --- a/src/main/common/tray.ts +++ b/src/main/common/tray.ts @@ -18,7 +18,13 @@ function createTray(window: BrowserWindow): Promise { icon = "./icons/icon@2x.png"; } const appIcon = new Tray(path.join(__static, icon)); - const contextMenu = Menu.buildFromTemplate([ + + const getShowAndHiddenHotKey = (): string => { + const config = global.OP_CONFIG.get(); + return config.perf.shortCut.showAndHidden; + } + + const createContextMenu = () => Menu.buildFromTemplate([ { label: "帮助文档", click: () => { @@ -38,7 +44,7 @@ function createTray(window: BrowserWindow): Promise { { type: "separator" }, { label: "显示窗口", - accelerator: "Alt+R", + accelerator: getShowAndHiddenHotKey(), click() { window.show(); }, @@ -67,9 +73,10 @@ function createTray(window: BrowserWindow): Promise { }, ]); appIcon.on("click", () => { - appIcon.popUpContextMenu(contextMenu); + appIcon.setContextMenu(createContextMenu()); + appIcon.popUpContextMenu(); }); - appIcon.setContextMenu(contextMenu); + appIcon.setContextMenu(createContextMenu()); resolve(appIcon); });