gcz 2 月之前
父节点
当前提交
cd2fe8ac68
共有 6 个文件被更改,包括 44 次插入21 次删除
  1. 二进制
      src/assets/loading.gif
  2. 1 1
      src/layout/index.vue
  3. 1 0
      src/styles/index.scss
  4. 29 17
      src/views/AIChat.vue
  5. 12 2
      src/views/DocSearch.vue
  6. 1 1
      src/views/Favorites.vue

二进制
src/assets/loading.gif


+ 1 - 1
src/layout/index.vue

@@ -48,7 +48,7 @@
       </el-menu>
       </div>
       <!-- 历史记录 -->
-      <div class="history-container" :class="{ 'is-collapse': userStore.isCollapse }">
+      <div class="history-container" v-if="historyList.length>0" :class="{ 'is-collapse': userStore.isCollapse }">
         <div class="history-title">
           <img src="../assets/history.png" alt="history"/>
           <span v-show="!userStore.isCollapse&&historyList.length>0">历史记录</span>

+ 1 - 0
src/styles/index.scss

@@ -42,6 +42,7 @@ think{
   bottom: 35px;
   left: $sidebar-width;
   right: 0;
+  z-index: 1000;
   p{
     margin-bottom: 8px;
   } 

+ 29 - 17
src/views/AIChat.vue

@@ -45,7 +45,8 @@
           <img :src="assistantAvatar" alt="assistant">
         </div>
         <div class="content">
-          <div class="typing">正在输入...</div>
+          <!-- <div class="typing">正在输入...</div> -->
+          <img class="loading-gif" src="@/assets/loading.gif" alt="loading">
         </div>
       </div>
     </div>
@@ -184,8 +185,9 @@ const toggleKnowledge = (id) => {
 const scrollToBottom = async () => {
   await nextTick()
   if (messagesRef.value) {
-    console.log('messagesRef.value',messagesRef.value);
-    messagesRef.value.scrollTop = messagesRef.value.scrollHeight
+    const scrollHeight = messagesRef.value.scrollHeight;
+    const extraSpace = 150; // 额外空间,确保内容不被输入框遮挡
+    messagesRef.value.scrollTop = scrollHeight + extraSpace;
   }
 }
 
@@ -253,6 +255,9 @@ const simulateStreamResponse = async (question) => {
     content: '',
     time: new Date()
   });
+  
+  // 立即滚动到底部确保"正在输入"可见
+  await scrollToBottom();
 
   const token = localStorage.getItem('token')
   
@@ -270,6 +275,13 @@ const simulateStreamResponse = async (question) => {
     try {
       const data = JSON.parse(event.data);
       
+      // 每次更新内容后都确保滚动到底部
+      if (data.data && data.data.answer) {
+        accumulatedText += data.data.answer;
+        messages.value[messageIndex].content = accumulatedText;
+        await scrollToBottom();
+      }
+
       if (data.data === true) {
        
         // 处理think标签
@@ -330,16 +342,6 @@ const simulateStreamResponse = async (question) => {
         await scrollToBottom();
         return;
       }
-
-      if (data.data && data.data.answer) {
-        // console.log('data.data.answer',data.data.answer);
-        // 累积接收到的文本
-        accumulatedText += data.data.answer;
-        // 临时显示文本
-        messages.value[messageIndex].content = accumulatedText;
-        await nextTick();
-        await scrollToBottom();
-      }
     } catch (error) {
       console.error('Parse error:', error);
     }
@@ -625,7 +627,7 @@ onMounted(async () => {
     transition: all 0.3s;
 
     &.chat-active {
-      padding-bottom: 100px;
+      padding-bottom: 150px;
     }
 
     .message {
@@ -664,6 +666,15 @@ onMounted(async () => {
         .avatar{
           margin-right: 10px;
         }
+        .content{
+          .loading-gif{
+            position: relative;
+            top: 10px;
+            left: 10px;
+            width: 30px;
+            height: 30px;
+          }
+        }
       }
       &.assistant .content .text {
         // background: rgba(255, 255, 255, 0.9);
@@ -708,7 +719,7 @@ onMounted(async () => {
     margin: 0 auto;
     padding: 20px;
     background: rgba(255, 255, 255, 0.9);
-    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
+    // box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
     backdrop-filter: blur(10px);
     border-radius: 20px;
     min-width: 800px;
@@ -717,8 +728,9 @@ onMounted(async () => {
       bottom: 0;
       left: $sidebar-width;
       right: 0;
-      padding: 20px;
-      box-shadow: none;
+      background: #fff;
+      z-index: 10; // 添加z-index确保在内容之上
+      // border-top: 1px solid #eee; // 可选:添加上边框
     }
 
     .input-container {

+ 12 - 2
src/views/DocSearch.vue

@@ -266,8 +266,18 @@ const handleCurrentChange = (val) => {
 }
 
 // 文档操作
-const viewDocument = (doc) => {
-  window.open(doc.fileUrl, '_blank')
+const viewDocument = async (doc) => {
+  // window.open(doc.fileUrl, '_blank')
+  try {
+    await downloadFile(doc.fileUrl, doc.fileName)
+    // 添加文件下载记录
+    await post('/admin/userHistoryLog/saveFileDownloadLog', {
+      relatedId: doc.id
+    })
+  } catch (error) {
+    console.log('error', error)
+    ElMessage.error('下载失败,请重试文件地址:'+doc.fileUrl)
+  }
 }
 
 const downloadDocument = async (doc) => {

+ 1 - 1
src/views/Favorites.vue

@@ -447,7 +447,7 @@ const handleItemClick = async (item) => {
         break;
       case 'file.search':
         try {
-          await downloadFile(item.fileUrl, item.fileName)
+          await downloadFile(item.fileUrl, item.fileName||item.name)
           // 添加文件下载记录
           await post('/admin/userHistoryLog/saveFileDownloadLog', {
             relatedId: item.relatedId