Initial commit: restructure to flat layout with ui/ and web/ at root
This commit is contained in:
68
web/electron/main.js
Normal file
68
web/electron/main.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
let mainWindow = null;
|
||||
let serverProcess = null;
|
||||
|
||||
function startServer() {
|
||||
console.log('Starting OpenChamber server...');
|
||||
|
||||
serverProcess = spawn('bun', ['run', 'start:web'], {
|
||||
cwd: path.join(__dirname, '..'),
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
detached: false
|
||||
});
|
||||
|
||||
serverProcess.on('error', (err) => {
|
||||
console.error('Server error:', err);
|
||||
});
|
||||
|
||||
serverProcess.on('exit', (code) => {
|
||||
console.log('Server exited with code:', code);
|
||||
});
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.loadURL('http://localhost:3000');
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
startServer();
|
||||
|
||||
setTimeout(() => {
|
||||
createWindow();
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (serverProcess) {
|
||||
serverProcess.kill();
|
||||
}
|
||||
app.quit();
|
||||
});
|
||||
|
||||
app.on('before-quit', () => {
|
||||
if (serverProcess) {
|
||||
serverProcess.kill();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user