feat: add shortcuts for the open main window

This commit is contained in:
purocean
2021-11-23 11:04:02 +08:00
parent 24bc042845
commit b40684abd3
2 changed files with 15 additions and 8 deletions
+14 -7
View File
@@ -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) => {
+1 -1
View File
@@ -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]
}