diff --git a/src/main/index.ts b/src/main/index.ts index 0d04a355..d8f51546 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -63,11 +63,18 @@ app.whenReady().then(() => { where: { id: 1 }, }); - WindowManager.createMainWindow(); + WindowManager.createSplashScreen(); + WindowManager.createSystemTray(userPreferences?.language || "en"); - WindowManager.mainWindow?.on("ready-to-show", () => { - autoUpdater.checkForUpdatesAndNotify(); + WindowManager.splashWindow?.on("ready-to-show", () => { + console.log("ready to show"); + autoUpdater.checkForUpdates().then((r) => { + console.log(r); + + WindowManager.splashWindow?.close(); + WindowManager.createMainWindow(); + }); }); }); }); diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts index 973a0c64..6d808e46 100644 --- a/src/main/services/window-manager.ts +++ b/src/main/services/window-manager.ts @@ -17,6 +17,7 @@ import { IsNull, Not } from "typeorm"; export class WindowManager { public static mainWindow: Electron.BrowserWindow | null = null; + public static splashWindow: Electron.BrowserWindow | null = null; private static loadURL(hash = "") { // HMR for renderer base on electron-vite cli. @@ -35,6 +36,49 @@ export class WindowManager { } } + private static loadSplashURL() { + // HMR for renderer base on electron-vite cli. + // Load the remote URL for development or the local html file for production. + if (is.dev && process.env["ELECTRON_RENDERER_URL"]) { + this.splashWindow?.loadURL( + `${process.env["ELECTRON_RENDERER_URL"]}#/splash` + ); + } else { + this.splashWindow?.loadFile( + path.join(__dirname, "../renderer/index.html"), + { + hash: "splash", + } + ); + } + } + + public static createSplashScreen() { + this.splashWindow = new BrowserWindow({ + width: 810, + height: 610, + minWidth: 810, + minHeight: 610, + titleBarStyle: "hidden", + ...(process.platform === "linux" ? { icon } : {}), + transparent: true, + frame: false, + alwaysOnTop: true, + trafficLightPosition: { x: 16, y: 16 }, + titleBarOverlay: { + symbolColor: "#DADBE1", + color: "#151515", + height: 34, + }, + webPreferences: { + preload: path.join(__dirname, "../preload/index.mjs"), + sandbox: false, + }, + }); + + this.loadSplashURL(); + } + public static createMainWindow() { // Create the browser window. this.mainWindow = new BrowserWindow({ diff --git a/src/renderer/src/main.tsx b/src/renderer/src/main.tsx index f44653cb..2098feb3 100644 --- a/src/renderer/src/main.tsx +++ b/src/renderer/src/main.tsx @@ -54,6 +54,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render( +