From b40684abd34174d0d03ad7bde4445d9e05677c8a Mon Sep 17 00:00:00 2001 From: purocean Date: Tue, 23 Nov 2021 11:04:02 +0800 Subject: [PATCH] feat: add shortcuts for the open main window --- src/main/app.ts | 21 ++++++++++++++------- src/main/shortcut.ts | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/app.ts b/src/main/app.ts index dfc61b7f..576474bb 100644 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -99,7 +99,7 @@ const createWindow = () => { }) } -const showWindow = () => { +const showWindow = (showInCurrentWindow = true) => { if (win) { const show = () => { if (win) { @@ -111,12 +111,19 @@ const showWindow = () => { } } - if (isMacos) { - show() + if (showInCurrentWindow) { + if (isMacos) { + // show in current workspace + win.setVisibleOnAllWorkspaces(true) + show() + win.setVisibleOnAllWorkspaces(false) + } else { + // hide first, then show in current desktop. for windows 10. + hideWindow() + setTimeout(show, 100) + } } else { - // hide first, then show in current desktop. for windows 10. - hideWindow() - setTimeout(show, 100) + show() } } else { createWindow() @@ -261,7 +268,7 @@ if (!gotTheLock) { }) app.on('activate', () => { - showWindow() + showWindow(false) }) app.on('web-contents-created', (_, webContents) => { diff --git a/src/main/shortcut.ts b/src/main/shortcut.ts index 47973e41..576fb4df 100644 --- a/src/main/shortcut.ts +++ b/src/main/shortcut.ts @@ -8,7 +8,7 @@ const platform = os.platform() type AcceleratorType = 'show-main-window' | 'open-in-browser' export const getAccelerator = (type: AcceleratorType) => { return { - 'show-main-window': platform === 'darwin' ? undefined : 'Super+N', + 'show-main-window': platform === 'darwin' ? 'Shift+Alt+M' : 'Super+N', 'open-in-browser': 'Super+Shift+B' }[type] }