impress_asr_input/src/preload.ts
impressionyang 2f7f5aae9e fix: 修复 TypeScript 类型错误
- 移除 MediaStream.tracks 属性访问(已被移除的 API)
- 仅使用标准的 getTracks() 方法

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-20 17:39:11 +08:00

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());
},
});