From 6a976fcb127e4dba744935a79c17335fb35545c4 Mon Sep 17 00:00:00 2001 From: Lexcubia Date: Mon, 28 Apr 2025 10:26:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(chat):=20=E4=BC=98=E5=8C=96=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E8=BE=93=E5=85=A5=E7=BB=84=E4=BB=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 WebSocket 接收数据逻辑,将实时文本追加到 existing value 中 - 移除未使用的 sendAsText 函数,简化代码结构 --- src/views/chat/components/VoiceInput.vue | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/views/chat/components/VoiceInput.vue b/src/views/chat/components/VoiceInput.vue index 12360b5..6f994bf 100644 --- a/src/views/chat/components/VoiceInput.vue +++ b/src/views/chat/components/VoiceInput.vue @@ -117,7 +117,7 @@ const wsConfig = { try { const data = JSON.parse(event.data) if (data.text) { - realTimeText.value = data.text + realTimeText.value += data.text } } catch (error) { console.error('WebSocket message parse error:', error) @@ -213,19 +213,6 @@ const confirmVoiceInput = async () => { closeVoiceModal() } -const sendAsText = () => { - if (isRecording.value) { - stopRecording() - isRecording.value = false - - if (realTimeText.value) { - emit('sendText', realTimeText.value) - } else { - ElMessage.warning('没有识别到文字') - } - } - closeVoiceModal() -} const startRecording = (stream) => { audioChunks = []