File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,12 @@ const startServer = require('./server')
6
6
const setMenu = require ( './menu' )
7
7
const setIPCEvents = require ( './ipc-events' )
8
8
9
- let win
9
+ const windows = [ ]
10
10
11
11
async function createWindow ( ) {
12
+ let win
12
13
let server
14
+
13
15
try {
14
16
// when starting the window run the server
15
17
server = await startServer ( )
@@ -32,6 +34,8 @@ async function createWindow() {
32
34
} ,
33
35
} )
34
36
37
+ windows . push ( win )
38
+
35
39
// open our server URL or the build directory in production
36
40
win . loadURL ( dev ? 'http://localhost:8000' : `file://${ resolve ( './build' ) } /index.html` )
37
41
@@ -46,6 +50,8 @@ async function createWindow() {
46
50
47
51
win . on ( 'close' , ( ) => {
48
52
win = null
53
+ const position = windows . indexOf ( win )
54
+ windows . splice ( position , 1 )
49
55
if ( server ) server . close ( )
50
56
} )
51
57
@@ -68,7 +74,7 @@ app.on('window-all-closed', () => {
68
74
} )
69
75
70
76
app . on ( 'activate' , ( ) => {
71
- if ( win === null ) {
77
+ if ( windows . length === 0 ) {
72
78
createWindow ( )
73
79
}
74
80
} )
You can’t perform that action at this time.
0 commit comments