mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
smoother way to show main window after splash
This commit is contained in:
parent
5667c813d9
commit
a817a26be1
4 changed files with 14 additions and 7 deletions
|
@ -42,7 +42,7 @@ const mockValuesForDebug = async () => {
|
|||
bytesPerSecond: 4568,
|
||||
},
|
||||
});
|
||||
await sleep(1000);
|
||||
await sleep(800);
|
||||
}
|
||||
|
||||
sendEvent({ type: "update-downloaded" });
|
||||
|
|
|
@ -6,8 +6,7 @@ const { autoUpdater } = updater;
|
|||
|
||||
const continueToMainWindow = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
autoUpdater.removeAllListeners();
|
||||
WindowManager.splashWindow?.close();
|
||||
WindowManager.createMainWindow();
|
||||
WindowManager.prepareMainWindowAndCloseSplash();
|
||||
};
|
||||
|
||||
registerEvent("continueToMainWindow", continueToMainWindow);
|
||||
|
|
|
@ -10,8 +10,7 @@ const restartAndInstallUpdate = async (_event: Electron.IpcMainInvokeEvent) => {
|
|||
autoUpdater.quitAndInstall(true, true);
|
||||
} else {
|
||||
autoUpdater.removeAllListeners();
|
||||
WindowManager.splashWindow?.close();
|
||||
WindowManager.createMainWindow();
|
||||
WindowManager.prepareMainWindowAndCloseSplash();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { IsNull, Not } from "typeorm";
|
|||
export class WindowManager {
|
||||
public static mainWindow: Electron.BrowserWindow | null = null;
|
||||
public static splashWindow: Electron.BrowserWindow | null = null;
|
||||
public static isReadyToShowMainWindow = false;
|
||||
|
||||
private static loadURL(hash = "") {
|
||||
// HMR for renderer base on electron-vite cli.
|
||||
|
@ -60,7 +61,8 @@ export class WindowManager {
|
|||
width: 380,
|
||||
height: 380,
|
||||
frame: false,
|
||||
alwaysOnTop: false,
|
||||
resizable: false,
|
||||
backgroundColor: "#1c1c1c",
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "../preload/index.mjs"),
|
||||
sandbox: false,
|
||||
|
@ -72,13 +74,14 @@ export class WindowManager {
|
|||
}
|
||||
|
||||
public static createMainWindow() {
|
||||
if (this.mainWindow) return;
|
||||
if (this.mainWindow || !this.isReadyToShowMainWindow) return;
|
||||
|
||||
this.mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 720,
|
||||
minWidth: 1024,
|
||||
minHeight: 540,
|
||||
backgroundColor: "#1c1c1c",
|
||||
titleBarStyle: "hidden",
|
||||
...(process.platform === "linux" ? { icon } : {}),
|
||||
trafficLightPosition: { x: 16, y: 16 },
|
||||
|
@ -112,6 +115,12 @@ export class WindowManager {
|
|||
});
|
||||
}
|
||||
|
||||
public static prepareMainWindowAndCloseSplash() {
|
||||
this.isReadyToShowMainWindow = true;
|
||||
this.splashWindow?.close();
|
||||
this.createMainWindow();
|
||||
}
|
||||
|
||||
public static redirect(hash: string) {
|
||||
if (!this.mainWindow) this.createMainWindow();
|
||||
this.loadURL(hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue