Fix main window maximizing from splash

The code checks whether the initial window starts maximized, if so, prevents the splash from starting maximized and leaves the main window maximized.
This commit is contained in:
Kdu 2024-05-24 15:02:45 -03:00
parent e5cffbe598
commit 4d72392f1d

View file

@ -20,6 +20,8 @@ export class WindowManager {
public static splashWindow: Electron.BrowserWindow | null = null; public static splashWindow: Electron.BrowserWindow | null = null;
public static isReadyToShowMainWindow = false; public static isReadyToShowMainWindow = false;
private static isMainMaximize = false;
private static loadURL(hash = "") { private static loadURL(hash = "") {
// HMR for renderer base on electron-vite cli. // HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production. // Load the remote URL for development or the local html file for production.
@ -71,6 +73,10 @@ export class WindowManager {
this.loadSplashURL(); this.loadSplashURL();
this.splashWindow.removeMenu(); this.splashWindow.removeMenu();
if (this.splashWindow?.isMaximized()) {
this.splashWindow?.unmaximize();
this.isMainMaximize = true;
}
} }
public static createMainWindow() { public static createMainWindow() {
@ -119,9 +125,7 @@ export class WindowManager {
this.isReadyToShowMainWindow = true; this.isReadyToShowMainWindow = true;
this.splashWindow?.close(); this.splashWindow?.close();
this.createMainWindow(); this.createMainWindow();
if (this.splashWindow?.isMaximized()) { if (this.isMainMaximize) this.mainWindow?.maximize();
this.mainWindow?.maximize();
}
} }
public static redirect(hash: string) { public static redirect(hash: string) {