It Works on my machine

This commit is contained in:
MasterAcnolo
2025-06-28 22:36:03 +02:00
parent accb55e538
commit 9d824f5c33
7 changed files with 7551 additions and 20 deletions

22
main.js
View File

@@ -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 dhabitude
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 douvrir 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();
});