external url direct handler
This commit is contained in:
Vendored
+1
@@ -36,6 +36,7 @@ interface Window {
|
||||
getRecordedVideoPath: () => Promise<{ success: boolean; path?: string; message?: string }>
|
||||
setRecordingState: (recording: boolean) => Promise<void>
|
||||
onStopRecordingFromTray: (callback: () => void) => () => void
|
||||
openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ipcMain, desktopCapturer, BrowserWindow } from 'electron'
|
||||
import { ipcMain, desktopCapturer, BrowserWindow, shell } from 'electron'
|
||||
import { startMouseTracking, stopMouseTracking, getTrackingData } from './mouseTracking'
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
@@ -134,4 +134,14 @@ export function registerIpcHandlers(
|
||||
onRecordingStateChange(recording, source.name)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('open-external-url', async (_, url: string) => {
|
||||
try {
|
||||
await shell.openExternal(url)
|
||||
return { success: true }
|
||||
} catch (error) {
|
||||
console.error('Failed to open URL:', error)
|
||||
return { success: false, error: String(error) }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -38,5 +38,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
const listener = () => callback()
|
||||
ipcRenderer.on('stop-recording-from-tray', listener)
|
||||
return () => ipcRenderer.removeListener('stop-recording-from-tray', listener)
|
||||
},
|
||||
openExternalUrl: (url: string) => {
|
||||
return ipcRenderer.invoke('open-external-url', url)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user