mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
74 lines
2.0 KiB
JavaScript
74 lines
2.0 KiB
JavaScript
/*
|
|
This file is part of Freedom Loader.
|
|
|
|
Copyright (C) 2025 MasterAcnolo
|
|
|
|
Freedom Loader is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License.
|
|
|
|
Freedom Loader is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
const { app, BrowserWindow } = require("electron");
|
|
const path = require("path");
|
|
const { logger, logSessionStart, logSessionEnd } = require("./server/logger");
|
|
|
|
let mainWindow;
|
|
|
|
async function createWindow() {
|
|
logger.info("Creation de la fenetre...");
|
|
if (mainWindow) {
|
|
logger.warn("La fenetre existe deja, pas de nouvelle creation");
|
|
return;
|
|
}
|
|
mainWindow = new BrowserWindow({
|
|
width: 1000,
|
|
height: 700,
|
|
webPreferences: {
|
|
nodeIntegration: false,
|
|
contextIsolation: true,
|
|
},
|
|
});
|
|
|
|
try {
|
|
await mainWindow.loadURL("http://localhost:8080");
|
|
logger.info("Fenetre chargee");
|
|
} catch (err) {
|
|
logger.error("Erreur chargement fenetre:", err);
|
|
}
|
|
|
|
mainWindow.on("closed", () => {
|
|
logger.info("Fenetre principale fermee");
|
|
mainWindow = null;
|
|
});
|
|
}
|
|
|
|
app.whenReady().then(async () => {
|
|
logSessionStart();
|
|
logger.info("App prete, demarrage du serveur Express...");
|
|
const expressServer = require("./server/server.js");
|
|
try {
|
|
await expressServer.startServer();
|
|
logger.info("Serveur Express demarre");
|
|
await createWindow();
|
|
} catch (error) {
|
|
logger.error("Erreur serveur ou fenetre :", error);
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.on("window-all-closed", () => {
|
|
logger.info("Toutes fenetres fermees, quitte l'app");
|
|
if (process.platform !== "darwin") app.quit();
|
|
});
|
|
|
|
app.on("before-quit", () => {
|
|
logSessionEnd();
|
|
}); |