Jelajahi Sumber

Merge branch 'master_feat_h5preview_20250305'

xdd 1 hari lalu
induk
melakukan
6c8dc2494b
1 mengubah file dengan 19 tambahan dan 7 penghapusan
  1. 19 7
      pages/index/index.vue

+ 19 - 7
pages/index/index.vue

@@ -190,16 +190,28 @@ export default {
             text: option.answer,
             options: []
           })
-          await this.delay(1000);
-          h5ChatItem.messages.push(nextMsg);
-        } else {
-          await this.delay(1000);
+        }
+        await this.delay(1000);
+        // 不管有没有 answer,都添加 nextMsg(如果存在)
+        if (nextMsg) {
           h5ChatItem.messages.push(nextMsg);
+          if(nextMsg.options){
+            return;
+          }
         }
 
-        while((nextMsg = h5ChatItem.agentMsg.shift()) && (!nextMsg.options || nextMsg.options.length === 0)) {
-          await this.delay(500+(Math.random()*1000)%500);
-          h5ChatItem.messages.push(nextMsg);
+        while (h5ChatItem.agentMsg.length > 0) {
+          nextMsg = h5ChatItem.agentMsg.shift();
+          if (nextMsg && (!nextMsg.options || nextMsg.options.length === 0)) {
+            await this.delay(500 + (Math.random() * 1000) % 500);
+            h5ChatItem.messages.push(nextMsg);
+          } else {
+            //重新放回去
+            if(nextMsg){
+              h5ChatItem.agentMsg.unshift(nextMsg);
+            }
+            break;
+          }
         }
 
         if (h5ChatItem.agentMsg.length === 0) {