From 3d089930fd1e3735dc9e2ae26d80e9e6837a7dcd Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 17 Aug 2025 22:27:14 +0800 Subject: [PATCH] fix: update mainWindowDefaultSize to use primary display dimensions - Changed mainWindowDefaultSize from static properties to a getter that retrieves the primary display's work area size, ensuring the main window adapts to different screen resolutions. - Adjusted logic for determining window dimensions to improve handling of window state and maximum size constraints. --- apps/desktop/layer/main/src/manager/window.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/desktop/layer/main/src/manager/window.ts b/apps/desktop/layer/main/src/manager/window.ts index 286db9eb4..e214364e8 100644 --- a/apps/desktop/layer/main/src/manager/window.ts +++ b/apps/desktop/layer/main/src/manager/window.ts @@ -22,9 +22,13 @@ import { loadDynamicRenderEntry } from "~/updater/hot-updater" const __dirname = fileURLToPath(new URL(".", import.meta.url)) class WindowManagerStatic { - static readonly mainWindowDefaultSize = { - height: 900, - width: 1600, + static get mainWindowDefaultSize() { + const primaryDisplay = screen.getPrimaryDisplay() + const { workAreaSize } = primaryDisplay + return { + height: workAreaSize.height, + width: workAreaSize.width, + } } // Window configuration properties for better DX @@ -346,8 +350,10 @@ class WindowManagerStatic { const defaultSize = WindowManagerStatic.mainWindowDefaultSize - const width = Math.min(windowState?.width || defaultSize.width, maxWidth) - const height = Math.min(windowState?.height || defaultSize.height, maxHeight) + const width = windowState?.width ? Math.min(windowState.width, maxWidth) : defaultSize.width + const height = windowState?.height + ? Math.min(windowState.height, maxHeight) + : defaultSize.height const ensureInBounds = (value: number, min: number, max: number): number => { return Math.max(min, Math.min(value, max))