@@ -77,9 +77,11 @@ const createWindow = () => {
77
77
} ;
78
78
// create dynamic window
79
79
const createDynamicWindow = ( file ) => {
80
+ createSplashScreen ( ) ;
80
81
dynamicWindow = new BrowserWindow ( {
81
82
width : isDev ? 1000 : 550 ,
82
83
height : 600 ,
84
+ show : false ,
83
85
webPreferences : {
84
86
preload : path . join ( __dirname , "preload.js" ) ,
85
87
nodeIntegration : true ,
@@ -98,6 +100,19 @@ const createDynamicWindow = (file) => {
98
100
if ( isDev ) {
99
101
dynamicWindow . webContents . openDevTools ( ) ;
100
102
}
103
+
104
+ dynamicWindow . once ( "ready-to-show" , ( ) => {
105
+ // dynamicWindow.show();
106
+ // if (splashScreen) {
107
+ // splashScreen.close();
108
+ // }
109
+ setTimeout ( ( ) => {
110
+ dynamicWindow . show ( ) ;
111
+ if ( splashScreen ) {
112
+ splashScreen . close ( ) ;
113
+ }
114
+ } , 500 ) ;
115
+ } ) ;
101
116
} ;
102
117
103
118
function createSplashScreen ( ) {
@@ -110,6 +125,7 @@ function createSplashScreen() {
110
125
webPreferences : {
111
126
nodeIntegration : true ,
112
127
} ,
128
+ icon : path . join ( __dirname , "./assets/icons/icon_512.png" ) ,
113
129
roundedCorners : true ,
114
130
transparent : true , // Set the window to be transparent
115
131
} ) ;
@@ -122,9 +138,11 @@ function createSplashScreen() {
122
138
}
123
139
124
140
const createURLWindow = ( file ) => {
141
+ createSplashScreen ( ) ;
125
142
dynamicWindow = new BrowserWindow ( {
126
143
width : isDev ? 1000 : 550 ,
127
144
height : 600 ,
145
+ show : false ,
128
146
webPreferences : {
129
147
preload : path . join ( __dirname , "preload.js" ) ,
130
148
nodeIntegration : true ,
@@ -140,9 +158,26 @@ const createURLWindow = (file) => {
140
158
dynamicWindow . setIcon ( path . join ( __dirname , "./assets/icons/icon_512.png" ) ) ;
141
159
// and load the index.html of the app.
142
160
dynamicWindow . loadURL ( "https://aethernex.vercel.app" ) ;
161
+ // did-fail-load
162
+ dynamicWindow . webContents . on (
163
+ "did-fail-load" ,
164
+ ( event , errorCode , errorDescription , validatedURL , isMainFrame ) => {
165
+ // Load a local HTML file if URL loading fails
166
+ dynamicWindow . loadFile ( path . join ( __dirname , "./app/error.html" ) ) ;
167
+ // console.log({event,errorCode,errorDescription,validatedURL,isMainFrame});
168
+ }
169
+ ) ;
143
170
if ( isDev ) {
144
171
dynamicWindow . webContents . openDevTools ( ) ;
145
172
}
173
+ dynamicWindow . once ( "ready-to-show" , ( ) => {
174
+ setTimeout ( ( ) => {
175
+ dynamicWindow . show ( ) ;
176
+ if ( splashScreen ) {
177
+ splashScreen . close ( ) ;
178
+ }
179
+ } , 500 ) ;
180
+ } ) ;
146
181
} ;
147
182
148
183
function showNotification ( { title, body } ) {
0 commit comments