File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
resources/js/electron-plugin/src Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const { autoUpdater } = electronUpdater;
2222class NativePHP {
2323 processes = [ ] ;
2424 schedulerInterval = undefined ;
25+ mainWindow = null ;
2526
2627 public bootstrap (
2728 app : CrossProcessExports . App ,
@@ -88,6 +89,17 @@ class NativePHP {
8889
8990 event . preventDefault ( ) ;
9091 } ) ;
92+
93+ // Handle deep linking for Windows
94+ if ( process . platform === 'win32' ) {
95+ app . on ( 'second-instance' , ( event , commandLine , workingDirectory ) => {
96+ if ( this . mainWindow ) {
97+ if ( this . mainWindow . isMinimized ( ) ) this . mainWindow . restore ( ) ;
98+ this . mainWindow . focus ( ) ;
99+ }
100+ this . handleDeepLink ( commandLine . pop ( ) ) ;
101+ } ) ;
102+ }
91103 }
92104
93105 private async bootstrapApp ( app : Electron . CrossProcessExports . App ) {
@@ -161,6 +173,15 @@ class NativePHP {
161173 } else {
162174 app . setAsDefaultProtocolClient ( deepLinkProtocol ) ;
163175 }
176+
177+
178+ if ( process . platform === 'win32' ) {
179+ const gotTheLock = app . requestSingleInstanceLock ( ) ;
180+ if ( ! gotTheLock ) {
181+ app . quit ( ) ;
182+ return ;
183+ }
184+ }
164185 }
165186 }
166187
You can’t perform that action at this time.
0 commit comments