-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
49 lines (40 loc) · 1.1 KB
/
main.js
File metadata and controls
49 lines (40 loc) · 1.1 KB
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
import { app, BrowserWindow } from 'electron';
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const server = express();
const PORT = 3456;
server.use(express.static(__dirname));
const serverInstance = server.listen(PORT, () => {
console.log(`Internal server running on http://localhost:${PORT}`);
});
function createWindow() {
const win = new BrowserWindow({
width: 1280,
height: 800,
title: 'MyGiulia Log Viewer',
icon: path.join(__dirname, 'icon.png'),
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
},
});
win.loadURL(`http://localhost:${PORT}/dist/index.html`);
win.maximize();
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
serverInstance.close(); // Stop server when app closes
app.quit();
}
});