فهرست منبع

feat: 修改不能正确调用提示词接口bug

zhouyuhao 6 ماه پیش
والد
کامیت
5cb4fcab79
2فایلهای تغییر یافته به همراه17 افزوده شده و 14 حذف شده
  1. 14 8
      src/views/AIRobotChat/src/AIRobotChat.vue
  2. 3 6
      src/views/Layout/src/LayoutView.vue

+ 14 - 8
src/views/AIRobotChat/src/AIRobotChat.vue

@@ -96,9 +96,10 @@ const progressStatus = {
 
 const isShowTips = ref(false) // 是否展示提示信息
 
+const isShowLoadingDots = ref(false) // 是否展示加载点
 const parseHtmlString = (data) => {
   const lines = data.split('\n')
-
+  isShowLoadingDots.value = true // 开始显示加载点
   function streamMarkdown() {
     const lastMsg: any = messages.value[messages.value.length - 1]
     let index = 0
@@ -110,6 +111,7 @@ const parseHtmlString = (data) => {
         index++
         scrollToBottom() // 滚动到底部
       } else {
+        isShowLoadingDots.value = false // 停止显示加载点
         clearInterval(timer)
       }
     }, 150)
@@ -149,7 +151,6 @@ const aiChat = (question, isPresetQuestion) => {
           res.data.is_fixedAnswer_end !== null || res.data.is_fixedAnswer_end !== undefined
             ? res.data.is_fixedAnswer_end
             : true
-        console.log('is_FixedAnswer.value', is_FixedAnswer.value)
         const { data } = res.data
         messages.value[messages.value.length - 1] = {
           id: serial_no.value,
@@ -162,7 +163,6 @@ const aiChat = (question, isPresetQuestion) => {
 
         parseHtmlString(data)
         scrollToBottom()
-        loadingAnswer.value = false
         queryTime.value = -1
       } else {
         loadingAnswer.value = false
@@ -193,7 +193,8 @@ const handleSend = (question, isPresetQuestion = true, isExternal = false) => {
   // 将用户内容添加到消息列表
   messages.value.push({
     type: 'user',
-    content: question
+    content: question,
+    isAnswer: true
   })
   !isPresetQuestion ? (userQuestion.value = '') : ''
   queryTime.value = 0
@@ -245,8 +246,8 @@ function handleScroll() {
 
   isShowHeaderShadow.value = !!messagesRef.value?.scrollTop
 }
-function scrollToBottom() {
-  if (!autoScroll.value || !messagesRef.value) return
+const scrollToBottom = (isScroll = false) => {
+  if (!isScroll && (!autoScroll.value || !messagesRef.value)) return
   nextTick(() => {
     if (messagesRef.value) {
       messagesRef.value.scrollTop = messagesRef.value.scrollHeight
@@ -376,7 +377,12 @@ defineExpose({
           <div v-html="msg.html || renderedMessage(msg.content)" class="markdown-body"></div>
         </div>
         <LoadingDots
-          v-if="index === messages.length - 1 && msg.isAnswer && loadingAnswer"
+          v-if="
+            index === messages.length - 1 &&
+            msg.isAnswer &&
+            isShowLoadingDots &&
+            msg.type === 'robot'
+          "
         ></LoadingDots>
         <!-- 评价  -->
         <div class="review" v-if="msg.isShowFeedback && msg.isAnswer">
@@ -420,7 +426,7 @@ defineExpose({
         </div>
       </div>
       <!-- 滚动到底部icon -->
-      <div v-if="showScrollButton" class="scroll-to-bottom-btn" @click="scrollToBottom">
+      <div v-if="showScrollButton" class="scroll-to-bottom-btn" @click="scrollToBottom(true)">
         <span class="font_family icon-icon_movedown_b"></span>
       </div>
     </div>

+ 3 - 6
src/views/Layout/src/LayoutView.vue

@@ -41,7 +41,9 @@ const handelClickAIDefault = async (item: any) => {
 watch(
   () => userStore.isLogin,
   (newVal) => {
-    if (!newVal) {
+    if (newVal) {
+      getPrompt()
+    } else {
       AIRobotChatref.value?.clearData()
     }
   }
@@ -53,11 +55,6 @@ const getPrompt = () => {
     }
   })
 }
-onMounted(() => {
-  if (userStore.isLogin) {
-    getPrompt()
-  }
-})
 </script>
 <template>
   <el-container class="layout-container">