-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathstart-electron.js
66 lines (50 loc) · 1.86 KB
/
start-electron.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This is to run KISS as an electron desktop app
const devMode = false;
const {app, BrowserWindow, globalShortcut} = require('electron');
const path = require('path');
const { spawn } = require('child_process');
let mainWindow;
let backendProcess;
app.on('ready', () => {
// Start the Java backend
backendProcess = spawn('./bld', ['develop-backend']);
backendProcess.stdout.on('data', (data) => {
console.log(`Backend: ${data}`);
});
backendProcess.stderr.on('data', (data) => {
console.error(`Backend Error: ${data}`);
});
backendProcess.on('close', (code) => {
console.log(`Backend process exited with code ${code}`);
});
if (devMode) {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true, // Optional, enables Node.js in frontend
contextIsolation: true // For compatibility, disable if needed
},
});
// Load your frontend file
//mainWindow.loadFile('src/main/frontend/index.html');
mainWindow.loadFile(path.join(__dirname, 'src/main/frontend', 'index.html'));
// Open DevTools for debugging
mainWindow.webContents.openDevTools();
// Register a keyboard shortcut for reload
globalShortcut.register('CommandOrControl+R', () => {
mainWindow.webContents.reload();
});
} else {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false, // Disable Node.js integration for security
contextIsolation: true, // Ensure a secure context
},
});
// Load the existing frontend
mainWindow.loadFile(path.join(__dirname, 'src/main/frontend', 'index.html'));
}
});