From 8be47b98212179eb4a99aef3ffcce726a7547d1b Mon Sep 17 00:00:00 2001 From: MasterAcnolo <68693319+MasterAcnolo@users.noreply.github.com> Date: Sat, 11 Apr 2026 22:36:42 +0200 Subject: [PATCH] Feat: Implement splash screen with progress indicators during startup --- app/splashManager.js | 37 +++++++++++++++++ app/windowManager.js | 1 + main.js | 12 ++++++ public/splash.html | 94 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 app/splashManager.js create mode 100644 public/splash.html diff --git a/app/splashManager.js b/app/splashManager.js new file mode 100644 index 0000000..5e43d17 --- /dev/null +++ b/app/splashManager.js @@ -0,0 +1,37 @@ +const { BrowserWindow } = require("electron"); +const path = require("path"); + +let splashWindow = null; + +function createSplashWindow() { + splashWindow = new BrowserWindow({ + width: 400, + height: 300, + frame: false, + transparent: true, + alwaysOnTop: true, + resizable: false, + skipTaskbar: true, + webPreferences: { + nodeIntegration: false, + contextIsolation: true, + }, + }); + + splashWindow.loadFile(path.join(__dirname, "../public/splash.html")); +} + +function closeSplashWindow() { + if (splashWindow) { + splashWindow.close(); + splashWindow = null; + } +} + +function setSplashProgress(step) { + if (splashWindow) { + splashWindow.webContents.executeJavaScript(`window.setProgress(${step})`); + } +} + +module.exports = { createSplashWindow, closeSplashWindow, setSplashProgress }; \ No newline at end of file diff --git a/app/windowManager.js b/app/windowManager.js index 4b4c273..9b06aea 100644 --- a/app/windowManager.js +++ b/app/windowManager.js @@ -20,6 +20,7 @@ async function createMainWindow() { minHeight: 800, frame: !configFeatures.customTopBar, devTools: !app.isPackaged, + show: false, webPreferences: { nodeIntegration: false, contextIsolation: true, diff --git a/main.js b/main.js index 9be3e35..f2016af 100644 --- a/main.js +++ b/main.js @@ -9,6 +9,7 @@ process.on("unhandledRejection", (reason) => { }); const { app } = require("electron"); +const { createSplashWindow, closeSplashWindow, setSplashProgress } = require("./app/splashManager"); const path = require("path"); const { logger, logSessionStart, logSessionEnd } = require("./server/logger"); @@ -40,24 +41,35 @@ if (!config.localMode) { app.whenReady().then(async () => { logSessionStart(); + createSplashWindow(); + if (!config.localMode && !checkNativeDependencies()) return; const { userYtDlp } = require("./server/helpers/path.helpers"); updateYtDlp(userYtDlp); try { + setSplashProgress(0); // Checking dependencies await require("./server/server").startServer(); + setSplashProgress(1); // Starting server registerIpcHandlers(getMainWindow); const themeFolderPath = config.localMode ? path.join(__dirname, "theme") : path.join(process.resourcesPath, "theme"); + setSplashProgress(2); // Loading themes await initThemes(themeFolderPath); + + setSplashProgress(3); // Almost ready await createMainWindow(); + await new Promise(resolve => setTimeout(resolve, 2000)); + + closeSplashWindow(); + getMainWindow().show(); if (configFeatures.discordRPC) startRPC(); if (configFeatures.autoUpdate) AutoUpdater(getMainWindow()); diff --git a/public/splash.html b/public/splash.html new file mode 100644 index 0000000..a74c92f --- /dev/null +++ b/public/splash.html @@ -0,0 +1,94 @@ + + +
+ + + + + +
+