Skip to content

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

:art: Improve the main window size after restarts https://github.com/siyuan-note/siyuan/issues/13732

Daniel7da5040baced
diff --git a/app/electron/main.js b/app/electron/main.js
index aaf698b558..e0fcdb8658 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -248,6 +248,7 @@ const initMainWindow = () => {
try {
oldWindowState = JSON.parse(fs.readFileSync(windowStatePath, "utf8"));
} catch (e) {
+ writeLog("read window state failed: " + e);
fs.writeFileSync(windowStatePath, "{}");
}
let defaultWidth;
@@ -258,7 +259,7 @@ const initMainWindow = () => {
defaultHeight = Math.floor(screen.getPrimaryDisplay().workAreaSize.height * 0.8);
workArea = screen.getPrimaryDisplay().workArea;
} catch (e) {
- console.error(e);
+ writeLog("get screen size failed: " + e);
}
const windowState = Object.assign({}, {
isMaximized: false,
@@ -270,7 +271,10 @@ const initMainWindow = () => {
height: defaultHeight,
}, oldWindowState);
- writeLog("window size [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + "], default [width=" + defaultWidth + ", height=" + defaultHeight + "], workArea [width=" + workArea.width + ", height=" + workArea.height + "]");
+ writeLog("window stat [x=" + windowState.x + ", y=" + windowState.y + ", width=" + windowState.width + ", height=" + windowState.height + "], " +
+ "default [x=0, y=0, width=" + defaultWidth + ", height=" + defaultHeight + "], " +
+ "old [x=" + oldWindowState.x + ", y=" + oldWindowState.y + ", width=" + oldWindowState.width + ", height=" + oldWindowState.height + "], " +
+ "workArea [width=" + workArea.width + ", height=" + workArea.height + "]");
let resetToCenter = false;
let x = windowState.x;