diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index bf29e9b..cb2b05f 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -1811,14 +1811,20 @@ export default { isRecording.value = false } + let pendingCallMode = false + const toggleCallMode = async () => { - if (isInCall.value || chatMode.value === 'call') { - await stopCallRecording() - await forceStopVoiceAndCall() - await resetToDefaultMode() + if (pendingCallMode || isInCall.value || chatMode.value === 'call') { + // 正在连接中 或 已在通话中 → 点击即退出 + if (!pendingCallMode) { + await stopCallRecording() + await forceStopVoiceAndCall() + await resetToDefaultMode() + } return } + pendingCallMode = true try { const hasPermission = await chatStore.requestMicrophonePermission() if (!hasPermission) { @@ -1845,9 +1851,7 @@ export default { if (success) { await chatStore.exitRealtimeCallMode() } - if (chatMode.value === 'none') { - await resetToDefaultMode() - } + await resetToDefaultMode() return } @@ -1859,9 +1863,9 @@ export default { } catch (error) { console.error('Enter call mode error:', error) ElMessage.error('连接实时语音服务失败') - if (chatMode.value === 'none') { - await resetToDefaultMode() - } + await resetToDefaultMode() + } finally { + pendingCallMode = false } }