From 7da5040baceddc49412bc17a127507c2c738599f Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Jan 2025 09:32:47 +0800 Subject: [PATCH] :art: Improve the main window size after restarts https://github.com/siyuan-note/siyuan/issues/13732 --- app/electron/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index aaf698b55..e0fcdb865 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;