mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
It Works on my machine
This commit is contained in:
22
main.js
22
main.js
@@ -1,7 +1,8 @@
|
||||
const { app, BrowserWindow } = require("electron");
|
||||
const path = require("path");
|
||||
|
||||
function createWindow() {
|
||||
async function createWindow() {
|
||||
console.log("🟢 Création de la fenêtre...");
|
||||
const win = new BrowserWindow({
|
||||
width: 1000,
|
||||
height: 700,
|
||||
@@ -11,16 +12,25 @@ function createWindow() {
|
||||
},
|
||||
});
|
||||
|
||||
// Charge ton frontend côté serveur Express
|
||||
win.loadURL("http://localhost:8080"); // Express tournera comme d’habitude
|
||||
win.loadURL("http://localhost:8080")
|
||||
.then(() => console.log("✅ Fenêtre chargée"))
|
||||
.catch(err => console.error("❌ Erreur chargement fenêtre:", err));
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
// lancer Express avant d’ouvrir Electron
|
||||
app.whenReady().then(async () => {
|
||||
console.log("🟢 App prête, démarrage du serveur Express...");
|
||||
const expressServer = require("./server/server.js");
|
||||
createWindow();
|
||||
try {
|
||||
await expressServer.startServer();
|
||||
console.log("✅ Serveur Express démarré");
|
||||
await createWindow();
|
||||
} catch (error) {
|
||||
console.error("❌ Erreur serveur ou fenêtre :", error);
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
console.log("🛑 Toutes fenêtres fermées, quitte l'app");
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user