1
- import { app , BrowserWindow , screen } from 'electron' ;
1
+ import { app , BrowserWindow , screen } from 'electron' ;
2
2
import * as path from 'path' ;
3
3
import * as fs from 'fs' ;
4
- import * as url from 'url' ;
5
4
6
5
let win : BrowserWindow = null ;
7
6
const args = process . argv . slice ( 1 ) ,
8
7
serve = args . some ( val => val === '--serve' ) ;
9
8
10
9
function createWindow ( ) : BrowserWindow {
11
10
12
- const electronScreen = screen ;
13
- const size = electronScreen . getPrimaryDisplay ( ) . workAreaSize ;
11
+ const size = screen . getPrimaryDisplay ( ) . workAreaSize ;
14
12
15
13
// Create the browser window.
16
14
win = new BrowserWindow ( {
@@ -20,7 +18,7 @@ function createWindow(): BrowserWindow {
20
18
height : size . height ,
21
19
webPreferences : {
22
20
nodeIntegration : true ,
23
- allowRunningInsecureContent : ( serve ) ? true : false ,
21
+ allowRunningInsecureContent : ( serve ) ,
24
22
contextIsolation : false , // false if you want to run e2e test with Spectron
25
23
} ,
26
24
} ) ;
@@ -40,11 +38,8 @@ function createWindow(): BrowserWindow {
40
38
pathIndex = '../dist/index.html' ;
41
39
}
42
40
43
- win . loadURL ( url . format ( {
44
- pathname : path . join ( __dirname , pathIndex ) ,
45
- protocol : 'file:' ,
46
- slashes : true
47
- } ) ) ;
41
+ const url = new URL ( path . join ( 'file:' , __dirname , pathIndex ) ) ;
42
+ win . loadURL ( url . href ) ;
48
43
}
49
44
50
45
// Emitted when the window is closed.
0 commit comments