File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ let urlToOpen: string | undefined = cli.input[0]?.includes('electronmon')
5050 : cli . input [ 0 ] ;
5151
5252let mainWindow : BrowserWindow | null = null ;
53-
53+ let boundsBeforeReload : Electron . Rectangle | null = null ;
5454initAppMetaHandlers ( ) ;
5555initWebviewContextMenu ( ) ;
5656initScreenshotHandlers ( ) ;
@@ -137,7 +137,19 @@ const createWindow = async () => {
137137 } ) ;
138138 initDevtoolsHandlers ( mainWindow ) ;
139139 initHttpBasicAuthHandlers ( mainWindow ) ;
140- const webPermissionHandlers = WebPermissionHandlers ( mainWindow ) ;
140+ ipcMain . on ( 'window-reload' , ( ) => {
141+ if ( ! mainWindow ) return ;
142+ boundsBeforeReload = mainWindow . getBounds ( ) ;
143+ mainWindow . webContents . reload ( ) ;
144+ } ) ;
145+
146+ mainWindow . webContents . on ( 'did-finish-load' , ( ) => {
147+ if ( boundsBeforeReload ) {
148+ mainWindow ?. setBounds ( boundsBeforeReload ) ;
149+ boundsBeforeReload = null ;
150+ }
151+ } ) ;
152+
141153
142154 // Add BROWSER_SYNC_HOST to the allowed Content-Security-Policy origins
143155 mainWindow . webContents . session . webRequest . onHeadersReceived (
Original file line number Diff line number Diff line change @@ -30,11 +30,7 @@ const getReloadMenu = (
3030 label : '&Reload' ,
3131 accelerator : 'CommandOrControl+R' ,
3232 click : ( ) => {
33- if ( isDev ) {
34- mainWindow . webContents . reload ( ) ;
35- return ;
36- }
37- mainWindow . webContents . send ( 'reload' , { } ) ;
33+ mainWindow . webContents . send ( 'window-reload' ) ;
3834 } ,
3935} ) ;
4036
You can’t perform that action at this time.
0 commit comments