mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 01:21:14 +08:00
This commit is contained in:
parent
c30b85d01f
commit
6bc63d35d2
@ -421,39 +421,54 @@ const boot = () => {
|
|||||||
tray.setContextMenu(contextMenu)
|
tray.setContextMenu(contextMenu)
|
||||||
}
|
}
|
||||||
|
|
||||||
const showWndMenu = {
|
const buildShowWndMenu = () => {
|
||||||
|
const ret = {
|
||||||
label: trayMenu.hideWindow,
|
label: trayMenu.hideWindow,
|
||||||
click: () => {
|
click: () => {
|
||||||
showHideWnd()
|
showHideWnd()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mainWindow.isVisible()) {
|
||||||
|
ret.label = trayMenu.hideWindow
|
||||||
|
} else {
|
||||||
|
ret.label = trayMenu.showWindow
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
const showHideWnd = () => {
|
const showHideWnd = () => {
|
||||||
if (!mainWindow.isVisible()) {
|
if (!mainWindow.isVisible()) {
|
||||||
if (mainWindow.isMinimized()) {
|
if (mainWindow.isMinimized()) {
|
||||||
mainWindow.restore()
|
mainWindow.restore()
|
||||||
}
|
}
|
||||||
mainWindow.show()
|
mainWindow.show()
|
||||||
showWndMenu.label = trayMenu.hideWindow
|
|
||||||
} else {
|
} else {
|
||||||
mainWindow.hide()
|
mainWindow.hide()
|
||||||
showWndMenu.label = trayMenu.showWindow
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetTrayMenu()
|
resetTrayMenu()
|
||||||
}
|
}
|
||||||
const setWndTopMenu = {
|
|
||||||
|
const buildSetWndTopMenu = () => {
|
||||||
|
const ret = {
|
||||||
label: trayMenu.setWindowTop,
|
label: trayMenu.setWindowTop,
|
||||||
click: () => {
|
click: () => {
|
||||||
setCancelWndTop()
|
setCancelWndTop()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if (mainWindow.isAlwaysOnTop()) {
|
||||||
|
ret.label = trayMenu.cancelWindowTop
|
||||||
|
} else {
|
||||||
|
ret.label = trayMenu.setWindowTop
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
const setCancelWndTop = () => {
|
const setCancelWndTop = () => {
|
||||||
if (!mainWindow.isAlwaysOnTop()) {
|
if (!mainWindow.isAlwaysOnTop()) {
|
||||||
mainWindow.setAlwaysOnTop(true)
|
mainWindow.setAlwaysOnTop(true)
|
||||||
setWndTopMenu.label = trayMenu.cancelWindowTop
|
|
||||||
} else {
|
} else {
|
||||||
mainWindow.setAlwaysOnTop(false)
|
mainWindow.setAlwaysOnTop(false)
|
||||||
setWndTopMenu.label = trayMenu.setWindowTop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetTrayMenu()
|
resetTrayMenu()
|
||||||
@ -461,7 +476,7 @@ const boot = () => {
|
|||||||
|
|
||||||
const buildTrayMenuTemplate = () => {
|
const buildTrayMenuTemplate = () => {
|
||||||
let ret = [
|
let ret = [
|
||||||
showWndMenu,
|
buildShowWndMenu(),
|
||||||
{
|
{
|
||||||
label: trayMenu.officialWebsite,
|
label: trayMenu.officialWebsite,
|
||||||
click: () => {
|
click: () => {
|
||||||
@ -491,7 +506,7 @@ const boot = () => {
|
|||||||
|
|
||||||
if ('win32' === process.platform) {
|
if ('win32' === process.platform) {
|
||||||
// Windows 端支持窗口置顶 https://github.com/siyuan-note/siyuan/issues/6860
|
// Windows 端支持窗口置顶 https://github.com/siyuan-note/siyuan/issues/6860
|
||||||
ret.splice(1, 0, setWndTopMenu)
|
ret.splice(1, 0, buildSetWndTopMenu())
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -502,7 +517,24 @@ const boot = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
globalShortcut.register(hotkey, () => {
|
globalShortcut.register(hotkey, () => {
|
||||||
showHideWnd()
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore()
|
||||||
|
if (!mainWindow.isVisible()) {
|
||||||
|
mainWindow.show()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mainWindow.isVisible()) {
|
||||||
|
if (!mainWindow.isFocused()) {
|
||||||
|
mainWindow.show()
|
||||||
|
} else {
|
||||||
|
mainWindow.hide()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mainWindow.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resetTrayMenu()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user