mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: add shortcuts for the open main window
This commit is contained in:
+14
-7
@@ -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) => {
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user