From 3842a3c6a62318a87db247f6783967eab06fdf55 Mon Sep 17 00:00:00 2001 From: yanghang Date: Fri, 18 Jul 2025 17:05:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=EF=BC=9A=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.js | 1 + src/pages/index/components/question.vue | 23 +++++++------- src/pages/index/components/talking-item.vue | 1 + src/pages/index/dialog.vue | 35 ++++++++++++++------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/api/common.js b/src/api/common.js index 7b3a4a92..845c484b 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -72,6 +72,7 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey='voice') => }; if (token) header['summary'] = token + console.log(`${base_url}${url}`) return new Promise((resolve, reject) => { uni.uploadFile({ url: `${base_url}${url}`, diff --git a/src/pages/index/components/question.vue b/src/pages/index/components/question.vue index 898c50ef..0d0b4d79 100644 --- a/src/pages/index/components/question.vue +++ b/src/pages/index/components/question.vue @@ -15,13 +15,13 @@ { emit('changePlay', unref(dataInfo)?.id) - if(talkVoiceObj.value && talkVoiceObj.value.src && talkVoiceObj.value.src === itemVoice.value) { + if(talkVoiceObj.value && talkVoiceObj.value.src) { talkVoiceObj.value.play() return }else{ - initVoice() talkVoiceObj.value.src = '' if(unref(dataInfo).talkingVoice){ setTimeout(()=>{ @@ -110,15 +109,15 @@ import { onUnload } from '@dcloudio/uni-app'; } } const initVoice = () => { + talkVoiceObj.value = uni.createInnerAudioContext() + talkVoiceObj.value.onEnded(()=>{ + emit('changePlay', '') + talkVoiceObj.value.src = '' + }) + talkVoiceObj.value.onError(()=>{ + talkVoiceObj.value.src = '' + }) if(unref(dataInfo).intrctWay === '02'){ - talkVoiceObj.value = uni.createInnerAudioContext() - talkVoiceObj.value.onEnded(()=>{ - emit('changePlay', '') - talkVoiceObj.value.src = '' - }) - talkVoiceObj.value.onError(()=>{ - talkVoiceObj.value.src = '' - }) itemVoice.value = unref(dataInfo).talkingVoice talkVoiceObj.value.src = itemVoice.value setTimeout(()=>{ diff --git a/src/pages/index/components/talking-item.vue b/src/pages/index/components/talking-item.vue index 197f2ea6..9b13471c 100644 --- a/src/pages/index/components/talking-item.vue +++ b/src/pages/index/components/talking-item.vue @@ -35,6 +35,7 @@ type: String } }) + watch(() => props.activeVoiceId, () => {},{deep: true,immediate: true}) watch(() => props.talkingInfo, () => {},{deep: true,immediate: true}) const { talkingType } = toRefs(props) const handleEvents = (type) => { diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue index 22b7cf44..a9638812 100644 --- a/src/pages/index/dialog.vue +++ b/src/pages/index/dialog.vue @@ -198,7 +198,8 @@ import { talkingText: body.intrctContent, isLoading: false, id: _id, - ...body + ...body, + talkingVoice: askData.value.talkingVoice }) return } @@ -352,21 +353,31 @@ import { isLoading: true }) scrollToBottomNow() + console.log(voicePath,111111111) commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}).then(res=>{ let _res = JSON.parse(res.data) if(_res.rtnCode === '0000'){ - askData.value = { - reqBatch: reqBatch.value, - intrctWay: '02',//01-文本;02-语音;03-图片 - intrctContent: _res.body.transContent, - bucketKey: _res.body.fileId, - ossFileAddr: _res.body.ossFileAddr, - talkingVoice: voicePath + if(!!(_res.body.transContent || '').trim()){ + askData.value = { + reqBatch: reqBatch.value, + intrctWay: '02',//01-文本;02-语音;03-图片 + intrctContent: _res.body.transContent, + bucketKey: _res.body.fileId, + ossFileAddr: _res.body.ossFileAddr, + talkingVoice: voicePath + } + sendMessage({ + "commond" : 'ASK', + "body": askData.value + }) + }else{ + talkingList.value.pop() + uni.showToast({ + title: '语音内容不能为空!', + icon: "none", + duration:1000 + }); } - sendMessage({ - "commond" : 'ASK', - "body": askData.value - }) }else{} }).catch(err=>{ talkingList.value.pop() From a2274a46cb951f09bf2b44c5805a57a6cb45e6c3 Mon Sep 17 00:00:00 2001 From: yanghang Date: Fri, 18 Jul 2025 17:34:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix=EF=BC=9B=20=E5=90=89=E7=A5=A5=E7=89=A9?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/dialog.vue | 36 ++++++++++++++++------- src/static/images/dialog/pet-bg-base.png | Bin 0 -> 352367 bytes src/static/images/dialog/pet-bg.png | Bin 0 -> 135813 bytes 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 src/static/images/dialog/pet-bg-base.png create mode 100644 src/static/images/dialog/pet-bg.png diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue index a9638812..89bc4911 100644 --- a/src/pages/index/dialog.vue +++ b/src/pages/index/dialog.vue @@ -13,9 +13,11 @@ AI问答 - - - Hi,我是{{'李想'}} + + + + + Hi,我是{{ userInfo.mascotInfo?.mascotName || ''}} 工作学习,我都能帮你! 试试他的能力 @@ -102,7 +104,7 @@