diff --git a/source/main/services/config.ts b/source/main/services/config.ts index 1ac606b1..5a156bfc 100644 --- a/source/main/services/config.ts +++ b/source/main/services/config.ts @@ -13,7 +13,8 @@ const DEFAULT_CONFIG = { windowHeight: 600, windowWidth: 800, windowX: null, - windowY: null + windowY: null, + isMaximize: false }; export async function getConfigValue(key: string): Promise { diff --git a/source/main/services/windows.ts b/source/main/services/windows.ts index 02d15859..8a52078d 100644 --- a/source/main/services/windows.ts +++ b/source/main/services/windows.ts @@ -23,6 +23,7 @@ async function createVaultWindow() { const height = await getConfigValue("windowHeight"); const x = await getConfigValue("windowX"); const y = await getConfigValue("windowY"); + const isMaximize = await getConfigValue("isMaximize"); const config: BrowserWindowConstructorOptions = { width, height, @@ -38,6 +39,9 @@ async function createVaultWindow() { config.y = y; } const win = new BrowserWindow(config); + if (isMaximize) { + win.maximize(); + } enableWebContents(win.webContents); win.on("closed", () => { win.removeAllListeners(); @@ -47,6 +51,15 @@ async function createVaultWindow() { "resize", debounce(() => handleWindowBoundsUpdate(win), 750, false) ); + + win.on("maximize", async () => { + await setConfigValue("isMaximize", win.isMaximized()); + }); + + win.on("unmaximize", async () => { + await setConfigValue("isMaximize", win.isMaximized()); + }); + win.on( "move", debounce(() => handleWindowBoundsUpdate(win), 750, false)