@@ -7,18 +7,24 @@ const imageSize = require('image-size');
77let io , server , browserWindows , ipc , apiProcess , loadURL ;
88let appApi , menu , dialogApi , notification , tray , webContents ;
99let globalShortcut , shellApi , screen , clipboard , autoUpdater ;
10- let splashScreen , mainWindowId , hostHook ;
10+ let splashScreen , hostHook ;
1111
1212const currentBinPath = path . join ( __dirname . replace ( 'app.asar' , '' ) , 'bin' ) ;
1313const manifestJsonFilePath = path . join ( currentBinPath , 'electron.manifest.json' ) ;
1414const manifestJsonFile = require ( manifestJsonFilePath ) ;
1515if ( manifestJsonFile . singleInstance ) {
16- const shouldQuit = app . requestSingleInstanceLock ( ) ;
17- app . on ( 'second-instance' , ( commandLine , workingDirectory ) => {
18- mainWindowId && BrowserWindow . fromId ( mainWindowId ) && BrowserWindow . fromId ( mainWindowId ) . show ( ) ;
16+ const mainInstance = app . requestSingleInstanceLock ( ) ;
17+ app . on ( 'second-instance' , ( ) => {
18+ const windows = BrowserWindow . getAllWindows ( ) ;
19+ if ( windows . length ) {
20+ if ( windows [ 0 ] . isMinimized ( ) ) {
21+ windows [ 0 ] . restore ( ) ;
22+ }
23+ windows [ 0 ] . focus ( ) ;
24+ }
1925 } ) ;
2026
21- if ( shouldQuit ) {
27+ if ( ! mainInstance ) {
2228 app . quit ( ) ;
2329 }
2430}
@@ -37,9 +43,9 @@ app.on('ready', () => {
3743} ) ;
3844
3945function isSplashScreenEnabled ( ) {
40- if ( manifestJsonFile . hasOwnProperty ( 'splashscreen' ) ) {
41- if ( manifestJsonFile . splashscreen . hasOwnProperty ( 'imageFile' ) ) {
42- return Boolean ( manifestJsonFile . splashscreen . imageFile ) ;
46+ if ( manifestJsonFile . hasOwnProperty ( 'splashscreen' ) ) {
47+ if ( manifestJsonFile . splashscreen . hasOwnProperty ( 'imageFile' ) ) {
48+ return Boolean ( manifestJsonFile . splashscreen . imageFile ) ;
4349 }
4450 }
4551
0 commit comments