-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
45 lines (39 loc) · 1.11 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
const { app, BrowserWindow, ipcMain } = require('electron');
const { Request } = require('./modules/api');
const { HandleAuthNFC } = require('./modules/nfc');
const { HandleAuthDev } = require('./modules/dev_auth');
require('dotenv').config('.env');
function createWindow() {
let win = new BrowserWindow({
width: 1024,
height: 768,
fullscreen: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
win.removeMenu();
win.loadFile('src/views/idle/idle.html');
// Switch back to idle if register finished
ipcMain.on('register-finished', (event, arg) => {
win.loadFile('src/views/idle/idle.html');
});
// Handle NFC authentication
if (process.env.SLOTH_ENV ? process.env.SLOTH_ENV.trim() === "dev" : false) {
win.webContents.openDevTools();
HandleAuthDev(win);
} else {
HandleAuthNFC(win);
}
}
ipcMain.on('request', (event, arg) => {
Request(arg.type, arg.url, arg.body, (err, data, statuscode) => {
event.reply(arg.name, {
err: err,
data: data,
statusCode: statuscode
});
});
});
app.on('ready', createWindow);