Просмотр исходного кода

[feat][ai聊天][自动滚动到底部]

hizhangling 4 дней назад
Родитель
Сommit
9fe69e15a2
1 измененных файлов с 14 добавлено и 2 удалено
  1. 14 2
      src/views/xjc-integratedmachine/common/ai/chat.vue

+ 14 - 2
src/views/xjc-integratedmachine/common/ai/chat.vue

@@ -123,7 +123,6 @@
     let activeIndex = ref(0);
 
     // 查看所有聊天记录
-    list();
     function list() {
         loadingHistoryRecord.value = true
         let queryForm = {
@@ -136,6 +135,9 @@
             setInterval(()=>{
                 scrollToBottom();
             }, 100);
+            if(resp.total == 0){
+                sayHi();
+            }
         })
     }
 
@@ -149,6 +151,16 @@
 
         })
     }
+
+    function sayHi() {
+        const botMsg = {
+            isUser: false,
+            content: '你好,我是来帮助你进行学习规划、选科辅导以及志愿填报的生涯教育专家。如果你有关于这些方面的问题,欢迎随时向我咨询!', // 增量填充
+            isTyping: false, // 显示加载动画
+        }
+        chatRecordList.value.push(botMsg)
+    }
+
     const sendMessage = () => {
         if (inputMessage.value.trim()) {
             sendRequest(inputMessage.value.trim())
@@ -531,7 +543,7 @@
         nextTick(()=>{
             initSpeechRecognition();
             initSpeechsynthesis();
-            sendMessage()
+            list();
         })
 
     })