fix: 修复 TypeScript 类型错误

- 移除 MediaStream.tracks 属性访问(已被移除的 API)
- 仅使用标准的 getTracks() 方法

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
impressionyang 2026-05-20 17:39:11 +08:00
parent b60f0061ed
commit 2f7f5aae9e
3 changed files with 11 additions and 1 deletions

View File

@ -229,7 +229,7 @@ export class AudioRecorder extends EventEmitter {
log(LogLevel.DEBUG, 'MediaStreamSource 已断开'); log(LogLevel.DEBUG, 'MediaStreamSource 已断开');
} }
if (this.stream) { if (this.stream) {
const tracks = this.stream.getTracks?.() || this.stream.tracks || []; const tracks = this.stream.getTracks?.() || [];
tracks.forEach((track: any) => track.stop?.()); tracks.forEach((track: any) => track.stop?.());
this.stream = null; this.stream = null;
log(LogLevel.DEBUG, '媒体流已停止'); log(LogLevel.DEBUG, '媒体流已停止');

View File

@ -151,6 +151,13 @@ ipcMain.handle('save-settings', async (_event: any, settings: Record<string, unk
return { success }; return { success };
}); });
ipcMain.handle('list-audio-devices', async () => {
logger.info('IPC: 请求音频设备列表');
// 设备列表需要在渲染进程中获取
// 返回一个标记,让渲染进程自行获取
return { available: true };
});
// 所有窗口关闭时退出应用 // 所有窗口关闭时退出应用
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
logger.info('所有窗口已关闭,退出应用'); logger.info('所有窗口已关闭,退出应用');

View File

@ -22,6 +22,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
// 文件检查 // 文件检查
checkFileExists: (path: string) => ipcRenderer.invoke('check-file-exists', path), checkFileExists: (path: string) => ipcRenderer.invoke('check-file-exists', path),
// 设备列表
listAudioDevices: () => ipcRenderer.invoke('list-audio-devices'),
// 事件监听 // 事件监听
onToggleRecording: (callback: () => void) => { onToggleRecording: (callback: () => void) => {
ipcRenderer.on('toggle-recording', () => callback()); ipcRenderer.on('toggle-recording', () => callback());