Skip to content

Commit 42026e6

Browse files
Add Windows support and deep linking configuration (#158)
1 parent ecca7dd commit 42026e6

File tree

1 file changed

+21
-0
lines changed
  • resources/js/electron-plugin/src

1 file changed

+21
-0
lines changed

resources/js/electron-plugin/src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const { autoUpdater } = electronUpdater;
2222
class 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

0 commit comments

Comments
 (0)