update: 拨号成功后开启自动录音

This commit is contained in:
lww155
2026-01-15 09:19:25 +08:00
parent ecd3e12a41
commit fa31096cd8
2 changed files with 23 additions and 0 deletions
+6
View File
@@ -83,6 +83,12 @@ if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => app.init());
} else {
app.init();
window.addEventListener('beforeunload', () => {
// 销毁定时器
if (app.uiController && app.uiController.wsTimer) {
clearInterval(app.uiController.wsTimer);
}
});
}
export default app;
@@ -11,6 +11,7 @@ class UIController {
this.visualizerCanvas = null;
this.visualizerContext = null;
this.audioStatsTimer = null;
this.wsTimer = null;
this.currentBackgroundIndex = 0;
this.backgroundImages = ['1.png', '2.png', '3.png'];
@@ -331,6 +332,20 @@ class UIController {
this.addChatMessage('配置已保存', false);
}
// 拨号成功后直接开始录音
dialAndRecord() {
const recordBtn = document.getElementById('recordBtn');
const wsHandler = getWebSocketHandler();
this.wsTimer = setInterval(() => {
if (wsHandler.isConnected() && wsHandler.websocket.onopen) {
clearInterval(this.wsTimer);
this.wsTimer = null;
recordBtn.click();
return;
}
}, 500);
}
// 处理连接按钮点击
async handleConnect() {
console.log('handleConnect called');
@@ -415,6 +430,8 @@ class UIController {
dialBtn.disabled = false;
dialBtn.querySelector('.btn-text').textContent = '挂断';
dialBtn.classList.add('dial-active');
this.dialAndRecord();
}
this.hideModal('settingsModal');