mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
refactor: update window close behavior for macOS and other platforms
- Modified the application to keep the app and servers running when all windows are closed on macOS, aligning with standard macOS behavior. - On other platforms, ensured that the server processes are stopped and the app quits when all windows are closed, preventing potential port conflicts.
This commit is contained in:
@@ -736,29 +736,29 @@ app.whenReady().then(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
// Stop the server when all windows are closed, even on macOS
|
// On macOS, keep the app and servers running when all windows are closed
|
||||||
// This prevents port conflicts when reopening the app
|
// (standard macOS behavior). On other platforms, stop servers and quit.
|
||||||
if (serverProcess && serverProcess.pid) {
|
|
||||||
console.log('[Electron] All windows closed, stopping server...');
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
try {
|
|
||||||
execSync(`taskkill /f /t /pid ${serverProcess.pid}`, { stdio: 'ignore' });
|
|
||||||
} catch (error) {
|
|
||||||
console.error('[Electron] Failed to kill server process:', (error as Error).message);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
serverProcess.kill('SIGTERM');
|
|
||||||
}
|
|
||||||
serverProcess = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (staticServer) {
|
|
||||||
console.log('[Electron] Stopping static server...');
|
|
||||||
staticServer.close();
|
|
||||||
staticServer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
if (serverProcess && serverProcess.pid) {
|
||||||
|
console.log('[Electron] All windows closed, stopping server...');
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
try {
|
||||||
|
execSync(`taskkill /f /t /pid ${serverProcess.pid}`, { stdio: 'ignore' });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[Electron] Failed to kill server process:', (error as Error).message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
serverProcess.kill('SIGTERM');
|
||||||
|
}
|
||||||
|
serverProcess = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (staticServer) {
|
||||||
|
console.log('[Electron] Stopping static server...');
|
||||||
|
staticServer.close();
|
||||||
|
staticServer = null;
|
||||||
|
}
|
||||||
|
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user