export working
This commit is contained in:
Vendored
+1
@@ -37,6 +37,7 @@ interface Window {
|
||||
setRecordingState: (recording: boolean) => Promise<void>
|
||||
onStopRecordingFromTray: (callback: () => void) => () => void
|
||||
openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>
|
||||
saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => Promise<{ success: boolean; path?: string; message?: string }>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ipcMain, desktopCapturer, BrowserWindow, shell } from 'electron'
|
||||
import { ipcMain, desktopCapturer, BrowserWindow, shell, app } from 'electron'
|
||||
import { startMouseTracking, stopMouseTracking, getTrackingData } from './mouseTracking'
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
@@ -144,4 +144,25 @@ export function registerIpcHandlers(
|
||||
return { success: false, error: String(error) }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('save-exported-video', async (_, videoData: ArrayBuffer, fileName: string) => {
|
||||
try {
|
||||
const downloadsPath = app.getPath('downloads')
|
||||
const videoPath = path.join(downloadsPath, fileName)
|
||||
await fs.writeFile(videoPath, Buffer.from(videoData))
|
||||
|
||||
return {
|
||||
success: true,
|
||||
path: videoPath,
|
||||
message: 'Video exported successfully'
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to save exported video:', error)
|
||||
return {
|
||||
success: false,
|
||||
message: 'Failed to save exported video',
|
||||
error: String(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+4
-1
@@ -41,5 +41,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
},
|
||||
openExternalUrl: (url: string) => {
|
||||
return ipcRenderer.invoke('open-external-url', url)
|
||||
}
|
||||
},
|
||||
saveExportedVideo: (videoData: ArrayBuffer, fileName: string) => {
|
||||
return ipcRenderer.invoke('save-exported-video', videoData, fileName)
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user