From b6eff31ba8b6164e51c536710166d473a12e1239 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 28 Apr 2024 12:29:32 +0800 Subject: [PATCH 1/3] :art: Support minimize the main window after auto launch on Windows https://github.com/siyuan-note/siyuan/issues/11145 --- app/electron/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index aab209531..be01e8f23 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -382,8 +382,8 @@ const initMainWindow = () => { // 主界面事件监听 currentWindow.once("ready-to-show", () => { - if (workspaces.length === 0 && openAsHidden) { - bootWindow.minimize(); + if (1 === workspaces.length && openAsHidden) { + currentWindow.minimize(); } else { currentWindow.show(); if (windowState.isMaximized) { @@ -444,6 +444,7 @@ const showWindow = (wnd) => { const initKernel = (workspace, port, lang) => { return new Promise(async (resolve) => { bootWindow = new BrowserWindow({ + show: false, width: Math.floor(screen.getPrimaryDisplay().size.width / 2), height: Math.floor(screen.getPrimaryDisplay().workAreaSize.height / 2), frame: false, @@ -640,6 +641,7 @@ for (let i = argStart; i < process.argv.length; i++) { // 跳过内置参数 if (arg.startsWith("--openAsHidden")) { openAsHidden = true; + writeLog("open as hidden"); } continue; } From 5a7097865c6f6f4293d8390163f9981c734a654d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 28 Apr 2024 12:47:37 +0800 Subject: [PATCH 2/3] :art: Support minimize the main window after auto launch on Windows https://github.com/siyuan-note/siyuan/issues/11145 --- app/electron/main.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index be01e8f23..203b864b2 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -230,6 +230,11 @@ const writeLog = (out) => { } }; +let openAsHidden = false; +isOpenAsHidden = function () { + return 1 === workspaces.length && openAsHidden; +} + const initMainWindow = () => { let windowStateInitialized = true; // 恢复主窗体状态 @@ -382,7 +387,7 @@ const initMainWindow = () => { // 主界面事件监听 currentWindow.once("ready-to-show", () => { - if (1 === workspaces.length && openAsHidden) { + if (isOpenAsHidden()) { currentWindow.minimize(); } else { currentWindow.show(); @@ -449,6 +454,7 @@ const initKernel = (workspace, port, lang) => { height: Math.floor(screen.getPrimaryDisplay().workAreaSize.height / 2), frame: false, backgroundColor: "#1e1e1e", + resizable: false, icon: path.join(appDir, "stage", "icon-large.png"), }); let bootIndex = path.join(appDir, "app", "electron", "boot.html"); @@ -568,9 +574,7 @@ const initKernel = (workspace, port, lang) => { try { const apiResult = await net.fetch(getServer() + "/api/system/version"); apiData = await apiResult.json(); - bootWindow.setResizable(false); bootWindow.loadURL(getServer() + "/appearance/boot/index.html"); - bootWindow.show(); break; } catch (e) { writeLog("get kernel version failed: " + e.message); @@ -634,7 +638,7 @@ let argStart = 1; if (!app.isPackaged) { argStart = 2; } -let openAsHidden = false; + for (let i = argStart; i < process.argv.length; i++) { let arg = process.argv[i]; if (arg.startsWith("--workspace=") || arg.startsWith("--openAsHidden") || arg.startsWith("--port=") || arg.startsWith("siyuan://")) { From bdd90724198463806c42e3295d08e07d2b55ede4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 28 Apr 2024 16:41:36 +0800 Subject: [PATCH 3/3] :art: Update text --- app/appearance/langs/en_US.json | 4 ++-- app/appearance/langs/es_ES.json | 4 ++-- app/appearance/langs/fr_FR.json | 4 ++-- app/appearance/langs/zh_CHT.json | 4 ++-- app/appearance/langs/zh_CN.json | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index c941558d7..2ebb723fc 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1492,8 +1492,8 @@ "241": "Drag to its subheading is not supported", "242": "The binding block already exists in the current database", "243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]", - "244": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]", - "245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. To exit normally, you need to use [Exit Application] in the right panel", + "244": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. In the future, please exit the program completely before shutting down the computer", + "245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. In the future, please use [Exit Application] in the right panel to exit normally", "246": "The document title cannot contain / and has been replaced with _" } } diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 0ccc3db69..cd98ebaba 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1492,8 +1492,8 @@ "241": "No se admite arrastrar a su subtítulo", "242": "El bloque de enlace ya existe en la base de datos actual", "243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]", - "244": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]", - "245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. Para salir normalmente, necesita usar [Salir de la aplicación] en el panel derecho", + "244": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. En el futuro, salga del programa por completo antes de apagar la computadora", + "245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. En el futuro, utilice [Salir de la aplicación] en el panel derecho para salir normalmente", "246": "El título del documento no puede contener / y ha sido reemplazado por _" } } diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index ad03ce672..f26ada006 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1492,8 +1492,8 @@ "241": "Le glisser vers son sous-titre n'est pas pris en charge", "242": "Le bloc de liaison existe déjà dans la base de données actuelle", "243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].", - "244": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]", - "245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]. Pour quitter normalement, vous devez utiliser [Quitter l'application] dans le panneau de droite", + "244": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Reconstruire l'index]. À l'avenir, veuillez quitter complètement le programme avant d'éteindre l'ordinateur", + "245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Reconstruire l'index]. À l'avenir, veuillez utiliser [Quitter l'application] dans le panneau de droite pour quitter normalement", "246": "Le titre du document ne peut pas contenir / et a été remplacé par _" } } diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index e02f5f100..9cc584088 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1492,8 +1492,8 @@ "241": "不支持拖曳為自己的子標題", "242": "目前資料庫中已經存在該綁定區塊", "243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]", - "244": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]", - "245": "上次使用後未正常退出,建議執行一次 [文件樹 - 重建索引],正常退出需使用右側欄面板中的 [退出應用]", + "244": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]。以後請完整退出程式後再關閉電腦", + "245": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]。以後請使用右側欄面板中的 [退出應用] 進行正常退出", "246": "文件標題不能包含 /,已經使用 _ 替換" } } diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 3c201da24..1b0a1e527 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1492,8 +1492,8 @@ "241": "不支持拖拽为自己的子标题", "242": "当前数据库中已经存在该绑定块", "243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]", - "244": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]", - "245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引],正常退出需使用右侧栏面板中的 [退出应用]", + "244": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]。以后请完整退出程序后再关闭电脑", + "245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]。以后请使用右侧栏面板中的 [退出应用] 进行正常退出", "246": "文档标题不能包含 /,已经使用 _ 替换" } }