-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
77 lines (66 loc) · 1.77 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
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
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
const path = require('path')
const appSettings = require('./electron/appSettings');
let win;
let isDev = !app.isPackaged
require('./electron/eventBus');
!isDev && require('./shared/sentry');
function createWindow() {
// Create the browser window.
win = new BrowserWindow({
show: false,
width: 560,
height: 690,
center: true,
resizable: isDev,
webPreferences: {
nodeIntegration: true,
scrollBounce: true,
devTools: isDev,
preload: path.join(__dirname, 'shared', 'sentry.js')
},
icon: path.join(__dirname, 'assets/icons/icon.png')
})
isDev && win.webContents.openDevTools();
const menu = Menu.buildFromTemplate([
{ role: 'fileMenu' },
{ role: 'editMenu'},
{
label: 'Debug',
submenu: [
{
label: 'Show browser',
click() {
appSettings.toggle('showBrowser');
},
type: 'checkbox',
checked: appSettings.get('showBrowser'),
accelerator: 'CmdOrCtrl+Shift+B'
},
]
}
])
Menu.setApplicationMenu(menu);
win.once('ready-to-show', () => {
win.show()
})
// and load the index.html of the app.
win.loadURL(
isDev
? 'http://localhost:1234/'
: `file://${path.join(__dirname, "./dist/index.html")}`
)
win.webContents.on("new-window", function(event, url) {
event.preventDefault();
});
win.on("closed", () => (win = null));
}
app.whenReady().then(createWindow)
ipcMain.on('anteater.error', () => {
console.log('Error triggered in main processes');
throw new Error('Error triggered in main processes');
});
ipcMain.on('anteater.crash', () => {
console.log('process.crash()');
process.crash();
});