@@ -6,6 +6,8 @@ const registerIPCHandlers = require('./backend/ipc.js')
6
6
const registerMenu = require ( './backend/menu.js' )
7
7
8
8
let win = null // main window
9
+ let splash = null
10
+ let splashTimestamp = null
9
11
10
12
// START APP
11
13
function createWindow ( ) {
@@ -17,23 +19,42 @@ function createWindow () {
17
19
nodeIntegration : false ,
18
20
webSecurity : true ,
19
21
enableRemoteModule : false ,
20
- preload : path . join ( __dirname , "preload.js" )
22
+ preload : path . join ( __dirname , "preload.js" ) ,
23
+ show : false
21
24
}
22
25
} )
23
26
// and load the index.html of the app.
24
27
win . loadFile ( 'ui/arduino/index.html' )
25
28
29
+ // If the app takes a while to open, show splash screen
30
+ // Create the splash screen
31
+ splash = new BrowserWindow ( {
32
+ width : 450 ,
33
+ height : 140 ,
34
+ transparent : true ,
35
+ frame : false ,
36
+ alwaysOnTop : true
37
+ } ) ;
38
+ splash . loadFile ( 'ui/arduino/splash.html' )
39
+ splashTimestamp = Date . now ( )
40
+
41
+ win . once ( 'ready-to-show' , ( ) => {
42
+ if ( Date . now ( ) - splashTimestamp > 1000 ) {
43
+ splash . destroy ( )
44
+ } else {
45
+ setTimeout ( ( ) => {
46
+ splash . destroy ( )
47
+ } , 500 )
48
+ }
49
+ win . show ( )
50
+ } )
51
+
26
52
registerIPCHandlers ( win , ipcMain , app )
27
53
registerMenu ( win )
28
54
29
55
app . on ( 'activate' , ( ) => {
30
56
if ( BrowserWindow . getAllWindows ( ) . length === 0 ) createWindow ( )
31
57
} )
32
- // app.on('window-all-closed', () => {
33
- // if (process.platform !== 'darwin') app.quit()
34
- // })
35
58
}
36
59
37
-
38
- // TODO: Loading splash screen
39
- app . whenReady ( ) . then ( createWindow )
60
+ app . on ( 'ready' , createWindow )
0 commit comments