mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-01 11:56:25 +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
6
surfsense_desktop/src/ipc/channels.ts
Normal file
6
surfsense_desktop/src/ipc/channels.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export const IPC_CHANNELS = {
|
||||
OPEN_EXTERNAL: 'open-external',
|
||||
GET_APP_VERSION: 'get-app-version',
|
||||
DEEP_LINK: 'deep-link',
|
||||
GET_CLIPBOARD_CONTENT: 'get-clipboard-content',
|
||||
} as const;
|
||||
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