liyongli 2 years ago
parent
commit
022da2c73e
1 changed files with 7 additions and 3 deletions
  1. 7 3
      src/view/chatQh/index.vue

+ 7 - 3
src/view/chatQh/index.vue

@@ -73,6 +73,7 @@ const inputText = ref('');
 let chatlist = ref([]);
 let session_hash = Math.random().toString(36).substring(2);
 
+let index = 0;
 if (!userData.value.UserId) {
   chat.value.push(
     ...[
@@ -107,23 +108,26 @@ function saveText() {
     text: '',
     type: 'robot',
   });
-  const idnex = chatlist.value.length === 0 ? 0 : chatlist.value.length - 1;
   const t = inputText.value;
   inputText.value = '';
+//   index++;
+  if (chatlist.value.length > 3) {
+    chatlist.value.shift();
+  }
   createSocket(
     ws => {
       const data = ws.data || {};
       if (data.msg == 'send_hash')
         ws.ws.send(
           JSON.stringify({
-            fn_index: idnex,
+            fn_index: index,
             session_hash,
           })
         );
       if (data.msg == 'send_data')
         ws.ws.send(
           JSON.stringify({
-            fn_index: idnex,
+            fn_index: index,
             data: [t, chatlist.value, 2048, 0.7, 0.95, null],
             event_data: null,
             session_hash,