forked from ForsakenNGS/hotsdrafter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (42 loc) · 1.34 KB
/
main.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
const path = require('path');
const { app, ipcMain, BrowserWindow } = require('electron');
const Twig = require('twig');
const fork = require('child_process').fork;
if (require('electron-squirrel-startup')) return app.quit();
const Installer = require("./src/installer.js");
if (Installer.handleSquirrelEvent()) {
// squirrel event handled and app will exit in 1000ms, so don't do anything else
return;
}
function createWindow () {
// Erstelle das Browser-Fenster.
let win = new BrowserWindow({
width: 1400,
height: 900,
minWidth: 1000,
minHeight: 600,
frame: false,
icon: path.join(__dirname, 'build/icon_64x64.png'),
webPreferences: {
nodeIntegration: true
}
});
win.setMenuBarVisibility(false);
// and load the index.twig.html of the app.
win.loadFile('gui/index.html');
let backend = fork("./src/backend.js");
let backendCallback = function(message) {
win.webContents.send(...message);
};
ipcMain.on("gui", (event, type, ...parameters) => {
if (type === "quit") {
backend.off("message", backendCallback);
backend.kill();
app.quit();
return;
}
backend.send([type, parameters]);
});
backend.on("message", backendCallback);
}
app.on('ready', createWindow);