mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 01:02:39 +02:00
refactor(desktop): extract IPC channels and handlers into src/ipc/
This commit is contained in:
parent
b6a7f0afa7
commit
fb4dbf04ae
3 changed files with 28 additions and 16 deletions
19
surfsense_desktop/src/ipc/handlers.ts
Normal file
19
surfsense_desktop/src/ipc/handlers.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { app, ipcMain, shell } from 'electron';
|
||||
import { IPC_CHANNELS } from './channels';
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
ipcMain.on(IPC_CHANNELS.OPEN_EXTERNAL, (_event, url: string) => {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
|
||||
shell.openExternal(url);
|
||||
}
|
||||
} catch {
|
||||
// invalid URL — ignore
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.GET_APP_VERSION, () => {
|
||||
return app.getVersion();
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue