From e05ab401650433cc7e767e08b482fb7a00be7bbd Mon Sep 17 00:00:00 2001 From: 石广澎 <shiguangpeng@163.com> Date: 星期三, 18 六月 2025 19:16:19 +0800 Subject: [PATCH] refactor(aiQuestions): 修复智能体流式回复解析问题 --- pages/aiQuestions/aiQuestions.vue | 48 ++++++++++++++++++++++++++---------------------- 1 files changed, 26 insertions(+), 22 deletions(-) diff --git a/pages/aiQuestions/aiQuestions.vue b/pages/aiQuestions/aiQuestions.vue index 00dece9..c194750 100644 --- a/pages/aiQuestions/aiQuestions.vue +++ b/pages/aiQuestions/aiQuestions.vue @@ -65,7 +65,7 @@ <view class="file-list" v-if="item.docInfo.length&&item.isEnd"> <view class="one-file" @click="uploadFile(file)" v-for="(file,findex) in item.docInfo" :key='findex'> <image :src="getImg(file.docFormat)" mode=""></image> - <text>{{file.docName}}</text> + <text style="font-size: 26rpx;">{{file.docName}}</text> </view> </view> <view v-if="item.isEnd||item.logSound" class="u-flex u-p-h-10 function-box"> @@ -74,7 +74,7 @@ <image src="/static/question/copy.png" mode=""></image> </view> </view> - <!-- + <!-- <view class="function-right"> <u-icon name="thumb-up-fill" @click='clickLikes(item)' v-if="item.isLike" color="#2468F2" size="40"></u-icon> @@ -84,7 +84,7 @@ color="#2468F2" size="40"></u-icon> <u-icon name="thumb-down" @click="clickDislikes(item)" v-else color="#98a1b2" size="40"></u-icon> - </view> + </view> --> </view> </view> @@ -100,7 +100,7 @@ <view v-else class="tips"> 鎴戞槸璐㈡斂AI鍔╂墜锛屽緢楂樺叴瑙佸埌浣狅紒鎴戝彲浠ュ洖绛旈」鐩枃妗d腑鐨勫悇绉嶉棶棰橈紝杈撳叆闂蹇潵浣撻獙鍚э紒 </view> - + <audio id="audio" src=""></audio> <view class="btmbox" :class="{'isOn':showKnow}"> <!-- <view v-if="!voiceFlg" class="know-btn" :class="{'active-btn':showKnow}" @click="showKnow=true"> @@ -130,8 +130,9 @@ <image src="/static/wd/i02.png" v-if="msg&&!isDisabled" class="btnimg" @click="tiWen" mode="widthFix" alt=""></image> </block> - </view> + </view> </view> + <view class="tipsMsg"> 鍐呭鐢� AI 鐢熸垚锛屼粎渚涘弬鑰冿紝鎮ㄦ嵁姝ゆ墍浣滃垽鏂強鎿嶄綔鍧囩敱鎮ㄨ嚜琛屾壙鎷呰矗浠汇��</view> <!--璁剧疆寮圭獥 --> <u-popup v-model="showSet" mode='top' border-radius="20"> <view class='set-box'> @@ -385,7 +386,6 @@ this.appId = options.id || 1 this.userId = options.userId || 1 // this.toCheck(this.appId) - console.log(options) if(options.knowId) { this.knowIds = options.knowId.split(',') } @@ -410,7 +410,6 @@ }, methods: { uploadFile(file) { - console.log(file.docPath); window.open(this.baseUrl + file.docPath) }, chooseThisLLM(e) { @@ -421,7 +420,6 @@ let res = await checkAppScope({ appId: e }) - console.log(res, '楠岃瘉'); if (res.data) { this.openRecord(); this.getDetails() @@ -460,7 +458,6 @@ pageSize: 10, pageNum: 1 }) - console.log(res); this.talkList = res.rows; }, toBack() { @@ -590,7 +587,6 @@ this.voicePageY = 0 this.voiceText = '鏉惧紑 鍙戦��' this.startRec() - console.log('touchstartVoice', this.voicePageY) }, // 鎼滅储鐭ヨ瘑搴� toSearch() { @@ -598,7 +594,6 @@ }, // 婊戝姩瑙﹀彂 touchmoveVoice(e) { - // console.log(e.changedTouches[0]) if (!this.voicePageY) { this.voicePageY = (e.changedTouches[0].pageY).toFixed(2) } @@ -619,7 +614,7 @@ // 鏉惧紑瑙﹀彂 touchendVoice() { this.stopRec(this.voiceStop); //褰曢煶缁撴潫 - console.log('鏉惧紑瑙﹀彂') + // console.log('鏉惧紑瑙﹀彂') }, // 涓鍥炵瓟 async isSuspend() { @@ -650,7 +645,7 @@ // 鎵撴柇瑙﹀彂 touchcancelVoice() { this.stopRec(this.voiceStop); //褰曢煶缁撴潫 - console.log('鎵撴柇瑙﹀彂') + // console.log('鎵撴柇瑙﹀彂') }, async tiWen() { if (this.$u.test.isEmpty(this.msg) && this.$u.test.isEmpty(this.recMsg)) { @@ -727,10 +722,8 @@ const reader = response.body.getReader(); if (this.suspend) { reader.cancel().then(() => { - console.log('娴佸紡鍝嶅簲宸插彇娑�'); if (controller) { controller.abort(); - console.log('涓fetch璇锋眰'); } }) return @@ -747,7 +740,9 @@ let docIds = null let isGetId = false let isThink = false + let count = 0 while (result) { + count++ if (this.suspend) break // done琛ㄧず娴佹槸鍚﹀凡缁忓畬鎴愯鍙� value鍖呭惈璇诲彇鍒扮殑鏁版嵁鍧� const { @@ -776,7 +771,7 @@ let asIdx = this.getContainedIdx(value, ansCode) if (asIdx !== -1) { isThink = false - curMsg.thinkLog += textDecoder.decode(value.slice(0, asIdx)) + curMsg.thinkLog += textDecoder.decode(value.slice(thkCode.length, asIdx)) dataArr = new Uint8Array([...value.slice(asIdx)]) } else { if(thkIdx===0){ @@ -791,9 +786,12 @@ // 妫�鏌ユ暟鎹暟缁勪腑鏄惁鍖呭惈鍊间负10鐨勫厓绱狅紝浠ョ‘瀹氭槸鍚﹂渶瑕佽幏鍙栨枃妗D isGetId = dataArr.includes(10) } - // dataArr = new Uint8Array([...dataArr, ...value]) - // isGetId = dataArr.includes(10) } + if (count === 1) { + const idx = dataArr.indexOf(10) + // 灏嗘暟鎹暟缁勪粠绱㈠紩浣嶇疆+1寮�濮嬬殑閮ㄥ垎涓庡綋鍓嶅�煎悎骞讹紝骞惰В鐮佷负瀛楃涓� + curMsg.aiLog = textDecoder.decode(dataArr.slice(idx + 1)) + } curMsg.debug = 0 this.intoView = ""; this.$nextTick(() => { @@ -815,7 +813,6 @@ this.msgList[this.msgList.length - 1].isPlay = 0 this.resetRec() } catch (err) { - console.log(err); if (this.msgList[this.msgList.length - 1].aiLog === '' || !this.msgList[this.msgList.length - 1] .isEnd) { this.msgList.pop() @@ -1370,10 +1367,17 @@ } } } - + .tipsMsg{ + position: fixed; + bottom: 0rpx; + text-align: center; + color: #c0c4cc; + height: 80rpx; + font-size: 26rpx; + } .btmbox { position: fixed; - bottom: 0; + bottom: 80rpx; height: 120rpx; background-color: #F3F5F9; display: flex; @@ -1573,7 +1577,7 @@ } text { - font-size: 30rpx; + font-size: 26rpx; color: #101828; line-height: 50rpx; font-weight: 400; -- Gitblit v1.9.1