- 移除 MediaStream.tracks 属性访问(已被移除的 API) - 仅使用标准的 getTracks() 方法 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
/**
|
|
* Electron 预加载脚本
|
|
* 注意:此文件需要 electron 依赖
|
|
*/
|
|
|
|
import { contextBridge, ipcRenderer } from 'electron';
|
|
|
|
// 暴露给渲染进程的 API
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
// 录音控制
|
|
startRecording: () => ipcRenderer.invoke('start-recording'),
|
|
stopRecording: () => ipcRenderer.invoke('stop-recording'),
|
|
|
|
// 剪贴板
|
|
copyToClipboard: (text: string) => ipcRenderer.invoke('copy-to-clipboard', text),
|
|
|
|
// 设置
|
|
getSettings: () => ipcRenderer.invoke('get-settings'),
|
|
saveSettings: (settings: Record<string, unknown>) =>
|
|
ipcRenderer.invoke('save-settings', settings),
|
|
|
|
// 文件检查
|
|
checkFileExists: (path: string) => ipcRenderer.invoke('check-file-exists', path),
|
|
|
|
// 设备列表
|
|
listAudioDevices: () => ipcRenderer.invoke('list-audio-devices'),
|
|
|
|
// 事件监听
|
|
onToggleRecording: (callback: () => void) => {
|
|
ipcRenderer.on('toggle-recording', () => callback());
|
|
},
|
|
onStopRecording: (callback: () => void) => {
|
|
ipcRenderer.on('stop-recording', () => callback());
|
|
},
|
|
});
|