-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
50 lines (42 loc) · 1.1 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
const electron = require('electron');
const electronRemoteMain = require("@electron/remote/main");
const app = electron.app;
try {
require('electron-debug')();
} catch (e) {
console.log('Package `electron-debug` not found, not enabling debug features.'); // eslint-disable-line no-console
}
const Pug = require('electron-pug');
let mainWindow; // Prevents the main window to be garbage collected
function onClosed() {
mainWindow = null;
}
function createMainWindow() {
const pug = Pug({ pretty: true }, {});
const win = new electron.BrowserWindow({
width: 1000,
height: 700,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
});
electronRemoteMain.initialize();
electronRemoteMain.enable(win.webContents);
win.loadURL(`file://${__dirname}/app/index.pug`);
win.on('closed', onClosed);
return win;
}
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
app.on('ready', () => {
mainWindow = createMainWindow();
});