1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const {app, BrowserWindow} = require('electron');
|
11 | const {join} = require('path');
|
12 |
|
13 | const argv = require('minimist')(process.argv.slice(2));
|
14 | const projectRoots = argv._;
|
15 |
|
16 | let mainWindow = null;
|
17 |
|
18 | app.on('window-all-closed', function() {
|
19 | app.quit();
|
20 | });
|
21 |
|
22 | app.on('ready', function() {
|
23 |
|
24 | mainWindow = new BrowserWindow({
|
25 | width: 800,
|
26 | height: 600,
|
27 | icon: join(__dirname, 'icons/icon128.png'),
|
28 | frame: false,
|
29 |
|
30 | webPreferences: {
|
31 | nodeIntegration: true,
|
32 | },
|
33 | });
|
34 |
|
35 |
|
36 | mainWindow.webContents.on('new-window', function(event, url) {
|
37 | event.preventDefault();
|
38 | require('electron').shell.openExternal(url);
|
39 | });
|
40 |
|
41 |
|
42 | mainWindow.loadURL('file://' + __dirname + '/app.html');
|
43 | mainWindow.webContents.executeJavaScript(
|
44 |
|
45 |
|
46 |
|
47 | 'window.devtools.setProjectRoots(' + JSON.stringify(projectRoots) + ')',
|
48 | );
|
49 |
|
50 |
|
51 | mainWindow.on('closed', function() {
|
52 | mainWindow = null;
|
53 | });
|
54 | });
|