fix: 文本阅读bug处理

This commit is contained in:
yanghang
2025-07-18 16:37:45 +08:00
parent 39e3965bf5
commit a806f4aeda
4 changed files with 20 additions and 18 deletions
+6 -15
View File
@@ -367,13 +367,17 @@ const audioCacheObj = computed(() => storageStore.audioObj)
},100)
}else{
voiceLoading.value = true
let _type = props.type == 2 ? 'ans' : props.type == 3 ? 'pgrh' : props.type == 4 ? 'qns' : ''
let _readId = props.type == 2 ? unref(dataInfo)?.intrctId : props.type == 3 ? unref(dataInfo)?.pgrphId : props.type == 4 ? unref(dataInfo)?.qnsId : ''
console.log(unref(dataInfo))
let _params = {
crsId: unref(dataInfo)?.crsId || '',
pgrphId: unref(dataInfo)?.pgrphId || '',
qnsId: unref(dataInfo)?.qnsId || '',
readType: readType,
readType: _type,// 2 文本回答 3, 段落信息 4 问题信息
teachNo: unref(teacherInfo)?.teacherNo, // 必填
content: _content
readId: _readId
// content: _content
}
@@ -388,19 +392,6 @@ const audioCacheObj = computed(() => storageStore.audioObj)
talkVoiceObj.value.src = url
talkVoiceObj.value.play()
}else{
// getAudioByText(_params).then(res=>{
// // uni.env.USER_DATA_PATH ||
// let filePath = `${'/'}/${dataInfo.value.id}.mp3`
// saveFile(res, filePath, () => {
// voiceLoading.value = false
// itemVoice.value = filePath
// talkVoiceObj.value.src = filePath
// talkVoiceObj.value.play()
// storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value)
// })
// }).catch(err=>{
// console.log(err)
// })
downloadVoiceFile(_url).then(res=>{
if(res?.data){
common.msg(res.data.message)
+5 -2
View File
@@ -63,6 +63,7 @@ import { onUnload } from '@dcloudio/uni-app';
// 声音播放初始化
const talkVoiceObj = ref(null)
const isPlaying = ref(false)
const voiceLoading = ref(false)
const translateLoading = ref(false)
@@ -88,6 +89,7 @@ import { onUnload } from '@dcloudio/uni-app';
const pauseVoice = () => {
if(!talkVoiceObj.value) return
talkVoiceObj.value.pause()
isPlaying.value = false
emit('changePlay', '')
}
const playVoice = () =>{
@@ -98,10 +100,11 @@ import { onUnload } from '@dcloudio/uni-app';
}else{
initVoice()
talkVoiceObj.value.src = ''
if(itemVoice.value){
if(unref(dataInfo).talkingVoice){
setTimeout(()=>{
talkVoiceObj.value.src = itemVoice.value
talkVoiceObj.value.src = unref(dataInfo).talkingVoice
talkVoiceObj.value.play()
isPlaying.value = true
},100)
}
}
@@ -4,6 +4,7 @@
v-if="talkingType === 'question'"
@changePlay="changePlay"
:dataInfo="talkingInfo"
:activeVoiceId="activeVoiceId"
></questionVue>
<answerVue
v-else-if="talkingType === 'answer'"
@@ -28,6 +29,10 @@
talkingInfo:{
default: () => ({}),
type: Object
},
activeVoiceId:{
default:'',
type: String
}
})
watch(() => props.talkingInfo, () => {},{deep: true,immediate: true})
+4 -1
View File
@@ -50,6 +50,7 @@
v-for="item in talkingList"
:talkingType="item.type"
:talkingInfo="item"
:activeVoiceId="activeVoiceTalkingItemId"
@handleEvents="talkItemEvents"
>
</TalkingItem>
@@ -139,7 +140,7 @@ import {
},time)
})
}
const activeVoiceTalkingItemId = ref('')
// ws 初始化逻辑
const reconnectTimer = null // 重连timer
const isManualClose = ref(false) // 是否手动关闭
@@ -246,6 +247,7 @@ import {
if(commond === 'ASK-ERR'){
console.log('提问失败,系统异常!')
console.log('body')
return
}
}else{
@@ -313,6 +315,7 @@ import {
break;
case 'changePlay':
console.log('播放/暂停')
activeVoiceTalkingItemId.value = id
break;
default:
break;