1
1
'use strict' ;
2
+
2
3
const electron = require ( 'electron' ) ;
3
4
// Module to control application life.
4
- const { app} = electron ;
5
+ const { app } = electron ;
5
6
// Module to create native browser window.
6
- const { BrowserWindow} = electron ;
7
+ const { BrowserWindow } = electron ;
7
8
8
9
let win , serve ;
9
10
const args = process . argv . slice ( 1 ) ;
@@ -15,56 +16,58 @@ if (serve) {
15
16
16
17
function createWindow ( ) {
17
18
18
- let electronScreen = electron . screen ;
19
- let size = electronScreen . getPrimaryDisplay ( ) . workAreaSize ;
19
+ let electronScreen = electron . screen ;
20
+ let size = electronScreen . getPrimaryDisplay ( ) . workAreaSize ;
20
21
21
- // Create the browser window.
22
- win = new BrowserWindow ( {
23
- x : 0 ,
24
- y : 0 ,
25
- width : size . width ,
26
- height : size . height
27
- } ) ;
22
+ // Create the browser window.
23
+ win = new BrowserWindow ( {
24
+ x : 0 ,
25
+ y : 0 ,
26
+ width : size . width ,
27
+ height : size . height
28
+ } ) ;
28
29
29
- let url = serve ?
30
- 'file://' + __dirname + '/dist/index.html' :
31
- 'file://' + __dirname + '/index.html' ;
30
+ let url = serve ?
31
+ 'file://' + __dirname + '/dist/index.html' :
32
+ 'file://' + __dirname + '/index.html' ;
32
33
33
- // and load the index.html of the app.
34
- win . loadURL ( url ) ;
34
+ // and load the index.html of the app.
35
+ win . loadURL ( url ) ;
35
36
36
- // Open the DevTools.
37
- if ( serve ) {
38
- win . webContents . openDevTools ( ) ;
39
- }
37
+ // Open the DevTools.
38
+ if ( serve ) {
39
+ win . webContents . openDevTools ( ) ;
40
+ }
40
41
41
- // Emitted when the window is closed.
42
- win . on ( 'closed' , ( ) => {
43
- // Dereference the window object, usually you would store windows
44
- // in an array if your app supports multi windows, this is the time
45
- // when you should delete the corresponding element.
46
- win = null ;
47
- } ) ;
42
+ // Emitted when the window is closed.
43
+ win . on ( 'closed' , ( ) => {
44
+ // Dereference the window object, usually you would store window
45
+ // in an array if your app supports multi windows, this is the time
46
+ // when you should delete the corresponding element.
47
+ win = null ;
48
+ } ) ;
48
49
}
49
50
51
+
50
52
// This method will be called when Electron has finished
51
53
// initialization and is ready to create browser windows.
52
54
// Some APIs can only be used after this event occurs.
53
55
app . on ( 'ready' , createWindow ) ;
54
56
55
57
// Quit when all windows are closed.
56
58
app . on ( 'window-all-closed' , ( ) => {
57
- // On OS X it is common for applications and their menu bar
58
- // to stay active until the user quits explicitly with Cmd + Q
59
- if ( process . platform !== 'darwin' ) {
60
- app . quit ( ) ;
61
- }
59
+ // On OS X it is common for applications and their menu bar
60
+ // to stay active until the user quits explicitly with Cmd + Q
61
+ if ( process . platform !== 'darwin' ) {
62
+ app . quit ( ) ;
63
+ }
62
64
} ) ;
63
65
64
66
app . on ( 'activate' , ( ) => {
65
- // On OS X it's common to re-create a window in the app when the
66
- // dock icon is clicked and there are no other windows open.
67
- if ( win === null ) {
68
- createWindow ( ) ;
69
- }
67
+ // On OS X it's common to re-create a window in the app when the
68
+ // dock icon is clicked and there are no other windows open.
69
+ if ( win === null ) {
70
+ createWindow ( ) ;
71
+ }
70
72
} ) ;
73
+
0 commit comments