-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
108 lines (72 loc) · 2.23 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* Main Process JavaScript */
// This script is the first to be ran and loads the HTML file that then loads the appropriate JS and CSS files.
const electron = require('electron');
const os = require('os');
// const ipcMain = require('electron').ipcMain;
const { app, BrowserWindow, ipcMain } = electron;
console.log('running index.js');
console.log(`Host Device: '${os.hostname()}'`);
app.on('browser-window-created', (e, window) => {
window.setMenu(null);
});
app.on('ready', () => {
let win = null;
const [ platform, arch, hostname ] = [ os.platform(), os.arch(), os.hostname() ];
if (hostname === 'PUNCH-PRESS' || (platform === 'linux' && arch === 'arm')) { // If running on a Raspberry Pi
console.log('Opening in deployment mode.');
win = new BrowserWindow({
// show: false,
// width: 1650,
// height: 950,
// fullscreen: true,
// frame: true,
kiosk: true,
// frame: false,
// backgroundColor: '#eaedf4',
backgroundThrottling: false,
// webPreferences: {
// nodeIntegration: false
// }
icon: `${__dirname}/icon.ico`
});
} else {
console.log('Opening in development mode.');
console.log('electron', electron);
win = new BrowserWindow({
// show: false,
width: 940,
height: 550,
// fullscreen: true,
// kiosk: true,
// frame: false,
// backgroundColor: '#eaedf4',
backgroundThrottling: false,
// webPreferences: {
// nodeIntegration: false
// }
icon: `${__dirname}/icon.ico`
});
}
win.loadURL(`file://${__dirname}/main.html`);
if (os.hostname() === 'BRAYDENS-LENOVO') win.webContents.openDevTools();
win.webContents.on('did-finish-load', () => {
console.log('Got \'did-finish-load\' event.');
});
// Called after all widgets initBody() functions and after initial visibility has been set and sidebar buttons have been created.
ipcMain.on('all-widgets-loaded', () => {
win.show();
win.focus();
console.log('Got ipcMain event: \'all-widgets-loaded\'.\n ...showing window.');
});
ipcMain.on('focus-window', () => {
win.focus();
});
ipcMain.on('open-dev-tools', () => {
win.webContents.openDevTools();
win.focus();
console.log('Got ipcMain event: \'open-dev-tools\'.');
});
win.on('close', () => {
win = null;
});
});