fix: Fix browser text to speech cannot resume and cancel

--bug=1052345 --user=刘瑞斌 【github#2352】【应用】使用浏览器内置TTS,切换历史记录内容播放会没有声音 https://www.tapd.cn/57709429/s/1657771
This commit is contained in:
CaptainB 2025-02-24 17:35:28 +08:00 committed by 刘瑞斌
parent 76e6b6e276
commit 5eec0f7975
3 changed files with 10 additions and 2 deletions

View File

@ -200,7 +200,7 @@ const playAnswerTextPart = () => {
if (audioList.value[currentAudioIndex.value] !== utterance.value?.text) {
window.speechSynthesis.cancel()
}
if (window.speechSynthesis.paused) {
if (window.speechSynthesis.paused && audioList.value[currentAudioIndex.value] === utterance.value?.text) {
window.speechSynthesis.resume()
return
}

View File

@ -176,7 +176,7 @@ const playAnswerTextPart = () => {
if (audioList.value[currentAudioIndex.value] !== utterance.value?.text) {
window.speechSynthesis.cancel()
}
if (window.speechSynthesis.paused) {
if (window.speechSynthesis.paused && audioList.value[currentAudioIndex.value] === utterance.value?.text) {
window.speechSynthesis.resume()
return
}

View File

@ -321,6 +321,14 @@ const clickListHandle = (item: any) => {
currentChatName.value = item.abstract
if (currentChatId.value !== 'new') {
getChatRecord()
//
if (window.speechSynthesis.paused && window.speechSynthesis.speaking) {
window.speechSynthesis.resume()
nextTick(() => {
window.speechSynthesis.cancel()
})
}
}
}
if (common.isMobile()) {