refactor(chat): 优化语音输入组件逻辑
- 修改 WebSocket 接收数据逻辑,将实时文本追加到 existing value 中 - 移除未使用的 sendAsText 函数,简化代码结构
This commit is contained in:
parent
276d358250
commit
6a976fcb12
|
@ -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 = []
|
||||
|
|
Loading…
Reference in New Issue