石广澎
2025-06-18 e05ab401650433cc7e767e08b482fb7a00be7bbd
pages/aiQuestions/aiQuestions.vue
@@ -386,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(',')
         }
@@ -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,8 +786,11 @@
                        // 检查数据数组中是否包含值为10的元素,以确定是否需要获取文档ID
                        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 = "";
@@ -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()