@@ -7,18 +7,24 @@ const imageSize = require('image-size');
7
7
let io , server , browserWindows , ipc , apiProcess , loadURL ;
8
8
let appApi , menu , dialogApi , notification , tray , webContents ;
9
9
let globalShortcut , shellApi , screen , clipboard , autoUpdater ;
10
- let splashScreen , mainWindowId , hostHook ;
10
+ let splashScreen , hostHook ;
11
11
12
12
const currentBinPath = path . join ( __dirname . replace ( 'app.asar' , '' ) , 'bin' ) ;
13
13
const manifestJsonFilePath = path . join ( currentBinPath , 'electron.manifest.json' ) ;
14
14
const manifestJsonFile = require ( manifestJsonFilePath ) ;
15
15
if ( 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
+ }
19
25
} ) ;
20
26
21
- if ( shouldQuit ) {
27
+ if ( ! mainInstance ) {
22
28
app . quit ( ) ;
23
29
}
24
30
}
@@ -37,9 +43,9 @@ app.on('ready', () => {
37
43
} ) ;
38
44
39
45
function 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 ) ;
43
49
}
44
50
}
45
51
0 commit comments