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] :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; }