From 6369b4fb4517d5b2b3997ae545445392d7bf5eb5 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 11 Jul 2025 17:16:04 +0800 Subject: [PATCH] fix: improve text handling and playback conditions in ChatOperationButton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1058408 --user=刘瑞斌 【应用管理】移动端自动播放没有声音,浏览器可正常播放 https://www.tapd.cn/62980211/s/1729308 --- .../operation-button/ChatOperationButton.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue index 149b9cd93..adaeb64cd 100644 --- a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue @@ -293,7 +293,7 @@ class AudioManage { const newTextList = textList.slice(this.textList.length) // 没有新增段落 if (newTextList.length <= 0) { - return + return 0 } newTextList.forEach((text, index) => { this.textList.push(text) @@ -429,7 +429,10 @@ class AudioManage { } if (text) { const textList = this.getTextList(text, is_end ? true : false) - this.appendTextList(textList) + if (this.appendTextList(textList) !== 0) { + // 没有新增段落 + return + } } // 如果存在在阅读的元素则直接返回 if (this.statusList.some((item) => [AudioStatus.PLAY_INT].includes(item))) { @@ -472,7 +475,7 @@ class AudioManage { setTimeout(() => { speechSynthesis.speak(audioElement) this.statusList[index] = AudioStatus.PLAY_INT - }, 100) + }, 500) } } } @@ -533,7 +536,7 @@ onMounted(() => { const record_id = data.record_id bus.emit('play:pause', record_id) if (props.data.record_id == record_id) { - if (props.tts && props.tts_autoplay) { + if (props.tts && props.tts_autoplay && data.is_end) { if (audioManage.value) { audioManage.value.play(props.data.answer_text, data.is_end) }