This commit is contained in:
Liang Ding 2022-12-17 17:21:51 +08:00
parent d13adf234b
commit 26c3ce610e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 40 additions and 60 deletions

View file

@ -421,8 +421,30 @@ const boot = () => {
tray.setContextMenu(contextMenu) tray.setContextMenu(contextMenu)
} }
const showWndMenu = {
label: trayMenu.hideWindow,
click: () => {
showHideWnd()
},
}
const showHideWnd = () => {
if (!mainWindow.isVisible()) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.show()
showWndMenu.label = trayMenu.hideWindow
} else {
mainWindow.hide()
showWndMenu.label = trayMenu.showWindow
}
resetTrayMenu()
}
const buildTrayMenuTemplate = () => { const buildTrayMenuTemplate = () => {
return [ let ret = [
showWndMenu,
{ {
label: trayMenu.officialWebsite, label: trayMenu.officialWebsite,
click: () => { click: () => {
@ -449,39 +471,24 @@ const boot = () => {
}, },
} }
] ]
}
const showWndMenu = { if ('win32' === process.platform) {
label: trayMenu.hideWindow, // Windows 端支持窗口置顶 https://github.com/siyuan-note/siyuan/issues/6860
click: () => { let changeWndTop = {
showHideWnd() label: trayMenu.setWindowTop,
}, click: () => {
} if (!mainWindow.isAlwaysOnTop()) {
const showHideWnd = () => { mainWindow.setAlwaysOnTop(true)
if (!mainWindow.isVisible()) { changeWndTop.label = trayMenu.cancelWindowTop
if (mainWindow.isMinimized()) { } else {
mainWindow.restore() mainWindow.setAlwaysOnTop(false)
} changeWndTop.label = trayMenu.setWindowTop
mainWindow.show() }
},
if ('win32' === process.platform || 'linux' === process.platform) { };
showWndMenu.label = trayMenu.hideWindow ret.splice(1, 0, changeWndTop)
const trayMenuTemplate = buildTrayMenuTemplate()
trayMenuTemplate.splice(0, 1, showWndMenu)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
}
} else {
mainWindow.hide()
if ('win32' === process.platform || 'linux' === process.platform) {
showWndMenu.label = trayMenu.showWindow
const trayMenuTemplate = buildTrayMenuTemplate()
trayMenuTemplate.splice(0, 1, showWndMenu)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
}
} }
return ret;
} }
ipcMain.on('siyuan-hotkey', (event, hotkey) => { ipcMain.on('siyuan-hotkey', (event, hotkey) => {
@ -501,34 +508,6 @@ const boot = () => {
tray.setToolTip('SiYuan v' + appVer) tray.setToolTip('SiYuan v' + appVer)
const trayMenuTemplate = buildTrayMenuTemplate() const trayMenuTemplate = buildTrayMenuTemplate()
// 插入显示/隐藏窗口菜单
trayMenuTemplate.splice(0, 0, showWndMenu)
let changeWndTop = {}
if ('win32' === process.platform) {
// Windows 端支持窗口置顶 https://github.com/siyuan-note/siyuan/issues/6860
changeWndTop = {
label: trayMenu.setWindowTop,
click: () => {
if (!mainWindow.isAlwaysOnTop()) {
mainWindow.setAlwaysOnTop(true)
changeWndTop.label = trayMenu.cancelWindowTop
trayMenuTemplate.splice(1, 1, changeWndTop)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
} else {
mainWindow.setAlwaysOnTop(false)
changeWndTop.label = trayMenu.setWindowTop
trayMenuTemplate.splice(1, 1, changeWndTop)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
}
},
};
trayMenuTemplate.splice(1, 0, changeWndTop)
}
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate) const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu) tray.setContextMenu(contextMenu)
tray.on('click', () => { tray.on('click', () => {

View file

@ -155,6 +155,7 @@ func DiffRepoSnapshots(left, right string) (ret *LeftRightDiff, err error) {
return return
} }
ret = &LeftRightDiff{}
luteEngine := NewLute() luteEngine := NewLute()
for _, addLeft := range diff.AddsLeft { for _, addLeft := range diff.AddsLeft {
title, err := parseTitleInSnapshot(addLeft.ID, repo, luteEngine) title, err := parseTitleInSnapshot(addLeft.ID, repo, luteEngine)