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,
|
bytesPerSecond: 4568,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await sleep(1000);
|
await sleep(800);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEvent({ type: "update-downloaded" });
|
sendEvent({ type: "update-downloaded" });
|
||||||
|
|
|
@ -6,8 +6,7 @@ const { autoUpdater } = updater;
|
||||||
|
|
||||||
const continueToMainWindow = async (_event: Electron.IpcMainInvokeEvent) => {
|
const continueToMainWindow = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
autoUpdater.removeAllListeners();
|
autoUpdater.removeAllListeners();
|
||||||
WindowManager.splashWindow?.close();
|
WindowManager.prepareMainWindowAndCloseSplash();
|
||||||
WindowManager.createMainWindow();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("continueToMainWindow", continueToMainWindow);
|
registerEvent("continueToMainWindow", continueToMainWindow);
|
||||||
|
|
|
@ -10,8 +10,7 @@ const restartAndInstallUpdate = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
autoUpdater.quitAndInstall(true, true);
|
autoUpdater.quitAndInstall(true, true);
|
||||||
} else {
|
} else {
|
||||||
autoUpdater.removeAllListeners();
|
autoUpdater.removeAllListeners();
|
||||||
WindowManager.splashWindow?.close();
|
WindowManager.prepareMainWindowAndCloseSplash();
|
||||||
WindowManager.createMainWindow();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { IsNull, Not } from "typeorm";
|
||||||
export class WindowManager {
|
export class WindowManager {
|
||||||
public static mainWindow: Electron.BrowserWindow | null = null;
|
public static mainWindow: Electron.BrowserWindow | null = null;
|
||||||
public static splashWindow: Electron.BrowserWindow | null = null;
|
public static splashWindow: Electron.BrowserWindow | null = null;
|
||||||
|
public static isReadyToShowMainWindow = 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.
|
||||||
|
@ -60,7 +61,8 @@ export class WindowManager {
|
||||||
width: 380,
|
width: 380,
|
||||||
height: 380,
|
height: 380,
|
||||||
frame: false,
|
frame: false,
|
||||||
alwaysOnTop: false,
|
resizable: false,
|
||||||
|
backgroundColor: "#1c1c1c",
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, "../preload/index.mjs"),
|
preload: path.join(__dirname, "../preload/index.mjs"),
|
||||||
sandbox: false,
|
sandbox: false,
|
||||||
|
@ -72,13 +74,14 @@ export class WindowManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createMainWindow() {
|
public static createMainWindow() {
|
||||||
if (this.mainWindow) return;
|
if (this.mainWindow || !this.isReadyToShowMainWindow) return;
|
||||||
|
|
||||||
this.mainWindow = new BrowserWindow({
|
this.mainWindow = new BrowserWindow({
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 720,
|
height: 720,
|
||||||
minWidth: 1024,
|
minWidth: 1024,
|
||||||
minHeight: 540,
|
minHeight: 540,
|
||||||
|
backgroundColor: "#1c1c1c",
|
||||||
titleBarStyle: "hidden",
|
titleBarStyle: "hidden",
|
||||||
...(process.platform === "linux" ? { icon } : {}),
|
...(process.platform === "linux" ? { icon } : {}),
|
||||||
trafficLightPosition: { x: 16, y: 16 },
|
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) {
|
public static redirect(hash: string) {
|
||||||
if (!this.mainWindow) this.createMainWindow();
|
if (!this.mainWindow) this.createMainWindow();
|
||||||
this.loadURL(hash);
|
this.loadURL(hash);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue