refactor(chat): 优化语音输入组件逻辑

- 修改 WebSocket 接收数据逻辑,将实时文本追加到 existing value 中
- 移除未使用的 sendAsText 函数,简化代码结构
This commit is contained in:
Lexcubia 2025-04-28 10:26:21 +08:00
parent 276d358250
commit 6a976fcb12
1 changed files with 1 additions and 14 deletions

View File

@ -117,7 +117,7 @@ const wsConfig = {
try { try {
const data = JSON.parse(event.data) const data = JSON.parse(event.data)
if (data.text) { if (data.text) {
realTimeText.value = data.text realTimeText.value += data.text
} }
} catch (error) { } catch (error) {
console.error('WebSocket message parse error:', error) console.error('WebSocket message parse error:', error)
@ -213,19 +213,6 @@ const confirmVoiceInput = async () => {
closeVoiceModal() closeVoiceModal()
} }
const sendAsText = () => {
if (isRecording.value) {
stopRecording()
isRecording.value = false
if (realTimeText.value) {
emit('sendText', realTimeText.value)
} else {
ElMessage.warning('没有识别到文字')
}
}
closeVoiceModal()
}
const startRecording = (stream) => { const startRecording = (stream) => {
audioChunks = [] audioChunks = []