fix(v1.0.3): fix startup window display, single instance lock, relative assets and obj packaging

This commit is contained in:
Michael committed 2026-05-21 19:17:07 +02:00
1 parent 47fb80602f
commit af479df65a
7 files changed
+58 -4

No files matched your search

+28
View File
@@ -3,8 +3,26 @@ const path = require('path');
const fs = require('fs');
const os = require('os');
// Autoriser le chargement de fichiers locaux via fetch sous le protocole file://
app.commandLine.appendSwitch('disable-web-security');
app.commandLine.appendSwitch('allow-file-access-from-files');
let mainWindow;
// ── Single Instance Lock ───────────────────────────────────────────────────
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
process.exit(0);
}
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});
// ── Logging Setup ───────────────────────────────────────────────────────────
function getLogPath() {
const userDataDir = app.getPath('userData');
@@ -207,6 +225,7 @@ function createWindow() {
transparent: true, // Permet la transparence (fond de fenêtre transparent)
backgroundColor: '#00000000', // Fond transparent
hasShadow: true,
show: false, // Cache la fenêtre au démarrage pour éviter les problèmes visuels de DWM
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true, // Sécurité Zero Trust active
@@ -216,6 +235,15 @@ function createWindow() {
},
});
mainWindow.once('ready-to-show', () => {
// Petit délai de sécurité (80ms) pour garantir la synchronisation DWM sous Windows
setTimeout(() => {
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.show();
}
}, 80);
});
loadApp().catch((error) => {
console.error("Echec du chargement de l'application.", error);
loadFallbackPage("Une erreur inattendue a interrompu le chargement de l'interface.");