This commit is contained in:
Liang Ding 2022-12-17 15:33:25 +08:00
parent d21dd185c4
commit a8201b8474
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 113 additions and 42 deletions

View file

@ -846,6 +846,16 @@
"xy": "%d years %s",
"max": "a long while %s"
},
"_trayMenu": {
"showWindow": "Show Window",
"hideWindow": "Hide Window",
"setWindowTop": "Set Window top",
"cancelWindowTop": "Cancel Window top",
"officialWebsite": "Visit official website",
"openSource": "Visit Project on Github",
"resetWindow": "Reset Window on restart",
"quit": "Quit application"
},
"_kernel": {
"0": "Query notebook failed",
"1": "Duplicated filename",

View file

@ -680,7 +680,6 @@
"export3": "Sólo texto de anclaje",
"export4": "Notas a pie de página",
"export5": "Ref. de anotación en PDF",
"export6": "Fusionar subdocumentos",
"export6": "Sobre el manejo del texto ancla en las anotaciones PDF al exportar",
"export7": "Nombre de archivo - Número de página - Texto ancla",
"export8": "Sólo texto ancla",
@ -847,6 +846,16 @@
"xy": "%d años %s",
"max": "mucho tiempo %s"
},
"_trayMenu": {
"showWindow": "Mostrar ventana",
"hideWindow": "Ocultar ventana",
"setWindowTop": "Establecer parte superior de la ventana",
"cancelWindowTop": "Cancelar ventana superior",
"officialWebsite": "Visita el sitio web oficial",
"openSource": "Visita el proyecto en Github",
"resetWindow": "Restablecer ventana al reiniciar",
"quit": "Salir de la aplicación"
},
"_kernel": {
"0": "Consulta al cuaderno de notas fallido",
"1": "Nombre de archivo duplicado",

View file

@ -846,6 +846,16 @@
"xy": "%d ans %s",
"max": "un bon moment %s"
},
"_trayMenu": {
"showWindow": "Afficher la fenêtre principale",
"hideWindow": "Masquer la fenêtre principale",
"setWindowTop": "Fenêtre en haut",
"cancelWindowTop": "Annuler le haut de la fenêtre",
"officialWebsite": "Visiter le site officiel",
"openSource": "Accéder aux projets open source GitHub",
"resetWindow": "Réinitialiser l'état de la fenêtre au redémarrage",
"quit": "Quitter le programme"
},
"_kernel": {
"0": "Échec du cahier de requêtes",
"1": "Nom de fichier dupliqué",

View file

@ -846,6 +846,16 @@
"xy": "%d 年%s",
"max": "很久%s"
},
"_trayMenu": {
"showWindow": "顯示主窗口",
"hideWindow": "隱藏主窗口",
"setWindowTop": "窗口置頂",
"cancelWindowTop": "取消窗口置頂",
"officialWebsite": "訪問官方網站",
"openSource": "訪問 GitHub 開源項目",
"resetWindow": "重啟時重置窗口",
"quit": "退出程序"
},
"_kernel": {
"0": "查詢筆記本失敗",
"1": "檔案名重複",

View file

@ -846,6 +846,16 @@
"xy": "%d 年%s",
"max": "很久%s"
},
"_trayMenu": {
"showWindow": "显示主窗口",
"hideWindow": "隐藏主窗口",
"setWindowTop": "窗口置顶",
"cancelWindowTop": "取消窗口置顶",
"officialWebsite": "访问官方网站",
"openSource": "访问 GitHub 开源项目",
"resetWindow": "重启时重置窗口",
"quit": "退出程序"
},
"_kernel": {
"0": "查询笔记本失败",
"1": "文件名重复",

View file

@ -393,48 +393,66 @@ const boot = () => {
globalShortcut.unregisterAll()
writeLog('exited ui')
})
ipcMain.on('siyuan-init', async () => {
let trayMenu = {
"showWindow": "Show Window",
"hideWindow": "Hide Window",
"setWindowTop": "Set Window top",
"cancelWindowTop": "Cancel Window top",
"officialWebsite": "Visit official website",
"openSource": "Visit Project on Github",
"resetWindow": "Reset Window on restart",
"quit": "Quit application"
}
ipcMain.on('siyuan-init', async (event, languages) => {
trayMenu = languages['_trayMenu'];
resetTrayMenu()
await fetch(getServer() + '/api/system/uiproc?pid=' + process.pid,
{method: 'POST'})
})
// 系统托盘菜单
const trayMenuTemplate = [
const resetTrayMenu = () => {
if ('win32' !== process.platform && 'linux' !== process.platform) {
return
}
const trayMenuTemplate = buildTrayMenuTemplate()
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
}
const buildTrayMenuTemplate = () => {
return [
{
label: 'Official Website',
label: trayMenu.officialWebsite,
click: () => {
shell.openExternal('https://b3log.org/siyuan/')
},
},
{
label: 'Open Source',
label: trayMenu.openSource,
click: () => {
shell.openExternal('https://github.com/siyuan-note/siyuan')
},
},
{
label: '中文反馈',
click: () => {
shell.openExternal('https://ld246.com/article/1649901726096')
},
},
{
label: 'Reset Window on restart',
label: trayMenu.resetWindow,
type: 'checkbox',
click: v => {
resetWindowStateOnRestart = v.checked
},
},
{
label: 'Quit',
label: trayMenu.quit,
click: () => {
mainWindow.webContents.send('siyuan-save-close', true)
},
}
]
}
const showWndMenu = {
label: 'Hide Window',
label: trayMenu.hideWindow,
click: () => {
showHideWnd()
},
@ -447,7 +465,8 @@ const boot = () => {
mainWindow.show()
if ('win32' === process.platform || 'linux' === process.platform) {
showWndMenu.label = "Hide Window"
showWndMenu.label = trayMenu.hideWindow
const trayMenuTemplate = buildTrayMenuTemplate()
trayMenuTemplate.splice(0, 1, showWndMenu)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
@ -456,7 +475,8 @@ const boot = () => {
mainWindow.hide()
if ('win32' === process.platform || 'linux' === process.platform) {
showWndMenu.label = "Show Window"
showWndMenu.label = trayMenu.showWindow
const trayMenuTemplate = buildTrayMenuTemplate()
trayMenuTemplate.splice(0, 1, showWndMenu)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
@ -480,6 +500,7 @@ const boot = () => {
tray = new Tray(path.join(appDir, 'stage', 'icon-large.png'))
tray.setToolTip('SiYuan v' + appVer)
const trayMenuTemplate = buildTrayMenuTemplate()
// 插入显示/隐藏窗口菜单
trayMenuTemplate.splice(0, 0, showWndMenu)
@ -487,17 +508,17 @@ const boot = () => {
if ('win32' === process.platform) {
// Windows 端支持窗口置顶 https://github.com/siyuan-note/siyuan/issues/6860
changeWndTop = {
label: 'Set Window top',
label: trayMenu.setWindowTop,
click: () => {
if (!mainWindow.isAlwaysOnTop()) {
mainWindow.setAlwaysOnTop(true)
changeWndTop.label = 'Cancel Window top'
changeWndTop.label = trayMenu.cancelWindowTop
trayMenuTemplate.splice(1, 1, changeWndTop)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
} else {
mainWindow.setAlwaysOnTop(false)
changeWndTop.label = 'Set Window top'
changeWndTop.label = trayMenu.setWindowTop
trayMenuTemplate.splice(1, 1, changeWndTop)
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
tray.setContextMenu(contextMenu)
@ -823,6 +844,7 @@ app.on('before-quit', (event) => {
})
const {powerMonitor} = require('electron')
const {build} = require("electron-builder");
powerMonitor.on('suspend', () => {
writeLog('system suspend')

View file

@ -131,7 +131,7 @@ export const onGetConfig = (isStart: boolean) => {
}
/// #if !BROWSER
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSE, window.siyuan.config.appearance.closeButtonBehavior);
ipcRenderer.send(Constants.SIYUAN_INIT);
ipcRenderer.send(Constants.SIYUAN_INIT, window.siyuan.languages);
ipcRenderer.send(Constants.SIYUAN_HOTKEY, hotKey2Electron(window.siyuan.config.keymap.general.toggleWin.custom));
/// #endif
if (!window.siyuan.config.uiLayout || (window.siyuan.config.uiLayout && !window.siyuan.config.uiLayout.left)) {