Skip to content

Commit e144882

Browse files
committed
fix: When there is only a voice file in the answer, an error is reported when reading it aloud.
--bug=1051784 --user=刘瑞斌 【应用编排】回答中只有语音文件的时候,朗读报错 https://www.tapd.cn/57709429/s/1649307
1 parent 495ac39 commit e144882

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<audio ref="audioPlayer" v-for="item in audioList" :key="item" controls hidden="hidden"></audio>
8080
</template>
8181
<script setup lang="ts">
82-
import { onMounted, ref } from 'vue'
82+
import { nextTick, onMounted, ref } from 'vue'
8383
import { useRoute } from 'vue-router'
8484
import { copyClick } from '@/utils/clipboard'
8585
import applicationApi from '@/api/application'
@@ -173,8 +173,11 @@ const playAnswerText = (text: string) => {
173173
// console.log(text)
174174
audioPlayerStatus.value = true
175175
// 分割成多份
176-
audioList.value = text.split(/(<audio[^>]*><\/audio>)/)
177-
playAnswerTextPart()
176+
audioList.value = text.split(/(<audio[^>]*><\/audio>)/).filter((item) => item.trim().length > 0)
177+
nextTick(()=>{
178+
// console.log(audioList.value, audioPlayer.value)
179+
playAnswerTextPart()
180+
})
178181
}
179182
180183
const playAnswerTextPart = () => {

0 commit comments

Comments
 (0)