fix: déplacer handlers IPC dans app.whenReady()
Les handlers ipcMain.handle() doivent être définis après app.whenReady() sinon ipcMain est undefined Résout: TypeError: Cannot read properties of undefined (reading 'handle')
This commit is contained in:
+27
-27
@@ -272,36 +272,36 @@ async function pingServer() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== IPC Handlers ==========
|
|
||||||
|
|
||||||
ipcMain.handle('server:start', async () => {
|
|
||||||
return await startServer();
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('server:stop', async () => {
|
|
||||||
return await stopServer();
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('server:status', async () => {
|
|
||||||
if (!serverStarted) {
|
|
||||||
return { running: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
const health = await pingServer();
|
|
||||||
return {
|
|
||||||
running: health.success,
|
|
||||||
health: health.data,
|
|
||||||
url: SERVER_URL
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('server:ping', async () => {
|
|
||||||
return await pingServer();
|
|
||||||
});
|
|
||||||
|
|
||||||
// ========== App Lifecycle ==========
|
// ========== App Lifecycle ==========
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
|
// Setup IPC Handlers (doit être après app.whenReady)
|
||||||
|
ipcMain.handle('server:start', async () => {
|
||||||
|
return await startServer();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('server:stop', async () => {
|
||||||
|
return await stopServer();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('server:status', async () => {
|
||||||
|
if (!serverStarted) {
|
||||||
|
return { running: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
const health = await pingServer();
|
||||||
|
return {
|
||||||
|
running: health.success,
|
||||||
|
health: health.data,
|
||||||
|
url: SERVER_URL
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('server:ping', async () => {
|
||||||
|
return await pingServer();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Créer fenêtre
|
||||||
createWindow();
|
createWindow();
|
||||||
createTray();
|
createTray();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user