implemented electron
This commit is contained in:
35
main.js
Normal file
35
main.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const { fork } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
let win;
|
||||
let backend;
|
||||
|
||||
function startBackend() {
|
||||
backend = fork(path.join(__dirname, 'server.js'));
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
win = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
}
|
||||
});
|
||||
|
||||
win.setMenu(null);
|
||||
|
||||
win.loadURL('http://localhost:3000');
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
startBackend();
|
||||
createWindow();
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (backend) backend.kill();
|
||||
app.quit();
|
||||
});
|
||||
Reference in New Issue
Block a user