Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Restore maximized window after hidden startup https://github.com/siyuan-note/siyuan/issues/19230

Daniel5e78dce07be1
diff --git a/app/electron/main.js b/app/electron/main.js
index 05dbe54cdb..aa1847de1a 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -1981,9 +1981,9 @@ const initMainWindow = (kernel = kernelPort, remoteAuthenticated = true) => {
height: defaultHeight,
}, oldWindowState);
- writeLog("window stat [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + "], " +
+ writeLog("window stat [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + ", isMaximized=" + windowState.isMaximized + "], " +
"default [x=0, y=0, width=" + defaultWidth + ", height=" + defaultHeight + "], " +
- "old [x=" + oldWindowState.x + ", y=" + oldWindowState.y + ", width=" + oldWindowState.width + ", height=" + oldWindowState.height + "]");
+ "old [x=" + oldWindowState.x + ", y=" + oldWindowState.y + ", width=" + oldWindowState.width + ", height=" + oldWindowState.height + ", isMaximized=" + oldWindowState.isMaximized + "]");
let resetToCenter = false;
let x = windowState.x;
@@ -2217,6 +2217,12 @@ const initMainWindow = (kernel = kernelPort, remoteAuthenticated = true) => {
ipcMain.once("siyuan-ready-to-show", () => {
clearTimeout(readyToShowTimeout); // 正常收到信号则取消超时兜底
if (isOpenAsHidden()) {
+ if (windowState.isMaximized) {
+ // 隐藏启动时延迟到首次还原再最大化,避免最大化操作提前显示窗口。
+ currentWindow.once("restore", () => {
+ currentWindow.maximize();
+ });
+ }
currentWindow.minimize();
} else {
currentWindow.show();