Add splash screen to launcher startup

Introduced a new splash screen (splash.html) and updated main.js to display it on startup before loading the main window. The splash screen is shown for 2.5 seconds as a placeholder for future loading logic, improving user experience during application launch.
This commit is contained in:
AMIAY
2026-01-22 07:59:27 +01:00
parent c0109575d6
commit b61c94d348
2 changed files with 211 additions and 4 deletions

37
main.js
View File

@@ -8,7 +8,7 @@ const profileManager = require('./backend/managers/profileManager');
logger.interceptConsole();
// Single instance lock - prevent multiple launcher instances
// Single instance lock
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
@@ -16,7 +16,6 @@ if (!gotTheLock) {
app.quit();
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, focus our window instead
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
@@ -96,11 +95,36 @@ function toggleDiscordRPC(enabled) {
console.log('Discord RPC disconnected successfully');
} catch (error) {
console.error('Error disconnecting Discord RPC:', error.message);
discordRPC = null; // Force null même en cas d'erreur
discordRPC = null;
}
}
}
function createSplashScreen() {
const splashWindow = new BrowserWindow({
width: 500,
height: 350,
frame: false,
transparent: true,
alwaysOnTop: true,
resizable: false,
skipTaskbar: true,
webPreferences: {
nodeIntegration: false,
contextIsolation: true
}
});
splashWindow.loadFile('GUI/splash.html');
splashWindow.center();
// close splash after 2.5s , need to implement a files check or whatever. just mock for now
setTimeout(() => {
splashWindow.close();
createWindow();
}, 2500);
}
function createWindow() {
mainWindow = new BrowserWindow({
width: 1280,
@@ -111,6 +135,7 @@ function createWindow() {
resizable: true,
alwaysOnTop: false,
backgroundColor: '#090909',
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
@@ -122,6 +147,10 @@ function createWindow() {
mainWindow.loadFile('GUI/index.html');
mainWindow.once('ready-to-show', () => {
mainWindow.show();
});
// Cleanup Discord RPC when window is closed
mainWindow.on('closed', () => {
console.log('Main window closed, cleaning up Discord RPC...');
@@ -195,7 +224,7 @@ app.whenReady().then(async () => {
// Initialize Profile Manager (runs migration if needed)
profileManager.init();
createWindow();
createSplashScreen();
setTimeout(async () => {
let timeoutReached = false;