From 3438297d98a80b8876cf43efdfee4a0216d81396 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期四, 08 八月 2024 20:10:21 +0800
Subject: [PATCH] feat: 修改bug

---
 src/views/session/sessionRecordsManager/index.vue |  139 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 96 insertions(+), 43 deletions(-)

diff --git a/src/views/session/sessionRecordsManager/index.vue b/src/views/session/sessionRecordsManager/index.vue
index 4b22809..15079e2 100644
--- a/src/views/session/sessionRecordsManager/index.vue
+++ b/src/views/session/sessionRecordsManager/index.vue
@@ -34,13 +34,13 @@
           <a-scrollbar
             class="left-list"
             style="
-              height: calc(100vh - 160px);
+              height: calc(100vh - 250px);
               overflow-y: auto;
               overflow-x: hidden;
             "
           >
             <div
-              class="item"
+              class="item left-list-item"
               v-for="session in sessionList"
               @click="querySessionDetail(session)"
               :class="{ isLeftActive: activeSessionId === session.id }"
@@ -214,16 +214,18 @@
                   maxRows: 5,
                 }"
               />
-            </div>
-            <div style="margin-left: 10px">
-              <!-- <icon-send size="32" /> -->
-              <a-button
-                :disabled="chatDis"
-                @click="sentClick"
-                type="primary"
-                size="large"
-                >鍙戦��</a-button
-              >
+              <div class="btn-send">
+                <!-- <icon-send size="32" /> -->
+                <a-button
+                  :disabled="chatDis"
+                  @click="sentClick"
+                  type="primary"
+                  style="border-radius: 24px"
+                  :loading="loading"
+                  size="large"
+                  >鍙戦��</a-button
+                >
+              </div>
             </div>
           </div>
         </a-card>
@@ -246,7 +248,19 @@
             </div>
           </div>
           <div class="right-tag">
-            <a-space>
+            <a-button type="primary" shape="round" size="mini" class="btn"
+              >鍏ㄩ儴
+            </a-button>
+            <a-button type="outline" shape="round" size="mini" class="btn"
+              >鏂囨。鍒涗綔
+            </a-button>
+            <a-button type="outline" shape="round" size="mini" class="btn"
+              >鐭ヨ瘑瀛︿範
+            </a-button>
+            <a-button type="outline" shape="round" size="mini" class="btn"
+              >鏁堢巼鎻愬崌
+            </a-button>
+            <!-- <a-space>
               <a-button type="primary" shape="round" size="mini" class="btn"
                 >鍏ㄩ儴
               </a-button>
@@ -256,12 +270,13 @@
               <a-button type="outline" shape="round" size="mini" class="btn"
                 >鐭ヨ瘑瀛︿範
               </a-button>
-            </a-space>
-            <a-space style="margin-top: 10px">
               <a-button type="outline" shape="round" size="mini" class="btn"
                 >鏁堢巼鎻愬崌
               </a-button>
-            </a-space>
+            </a-space> -->
+            <!-- <a-space style="margin-top: 10px">
+             
+            </a-space> -->
           </div>
           <div class="right-list">
             <div class="right-item">
@@ -315,13 +330,13 @@
     getSessionDetailsApi,
     sessionListApi,
   } from '@/api/session';
-  import { getAuthorization } from "@/utils/auth";
-
+  import { getAuthorization } from '@/utils/auth';
 
   const sessionDetailList = ref([]); //鏍规嵁浼氳瘽id鍑烘潵鐨勪細璇濊鎯�
   const sessionList = ref([]); //浼氳瘽鍒楄〃
   const modalObj = reactive({ add: false });
   const chatDis = ref(false);
+  const loading = ref(false);
 
   const currIndex = ref(0);
   const displayedText = ref(''); // 姝e湪鏄剧ず鐨勬枃瀛�
@@ -351,25 +366,36 @@
   const sendMessage = async (event) => {
     event.preventDefault();
     chatDis.value = true;
+    loading.value = true;
     if (!activeSessionId.value) {
       Message.warning('璇烽�夋嫨浼氳瘽');
+      chatDis.value = false;
+      loading.value = false;
       return;
     }
+
+    // if (displayedText.value) {
+    //   querySessionList();
+    // }
+
     if (inputMsg.value) {
-      sessionDetailList.value.push({ "content": inputMsg.value, "role": "user" });
-      sessionDetailList.value.push({  "role": "last" });
+      sessionDetailList.value.push({ content: inputMsg.value, role: 'user' });
+      sessionDetailList.value.push({ role: 'last' });
       refreshScroll();
-      const response = await fetch("/api/tech/cloudminds/query?modeltype=localragflow", {
-        method: 'POST',
-        headers: {
-          'Authorization': getAuthorization(),
-          'Content-Type': 'application/json',
-        },
-        body: JSON.stringify({
-          conversation_id: activeSessionId.value,
-          messages: inputMsg.value,
-        }),
-      });
+      const response = await fetch(
+        '/api/tech/cloudminds/query?modeltype=localragflow',
+        {
+          method: 'POST',
+          headers: {
+            'Authorization': getAuthorization(),
+            'Content-Type': 'application/json',
+          },
+          body: JSON.stringify({
+            conversation_id: activeSessionId.value,
+            messages: inputMsg.value,
+          }),
+        }
+      );
 
       const reader = response?.body
         ?.pipeThrough(new TextDecoderStream())
@@ -380,12 +406,12 @@
         const x = await reader?.read();
         if (x) {
           const { done, value } = x;
+          console.log(x, 999);
           try {
             const val = JSON.parse(value?.data || '');
             const d = val?.data;
-            if (typeof d !== "boolean") {
-
-              console.info("data:", d);
+            if (typeof d !== 'boolean') {
+              console.info('data:', d);
               streamStr.value = d.content;
               startDisplayStr();
             }
@@ -394,11 +420,14 @@
           }
           if (done) {
             console.info('done');
+            displayedText.value = '';
+            querySessionList();
             break;
           }
         }
       }
-      chatDis.value=false;
+      chatDis.value = false;
+      loading.value = false;
       inputMsg.value = '';
     } else {
       Message.warning('娑堟伅涓嶈兘涓虹┖');
@@ -424,6 +453,8 @@
     const { code, data } = await sessionListApi(selectValue.value);
     if (code === 200) {
       sessionList.value = data;
+      activeSessionId.value = data[0].id;
+      querySessionDetail(data[0]);
     } else {
       Message.warning('鏌ヨ澶辫触');
     }
@@ -459,7 +490,13 @@
 </script>
 <style scoped lang="scss">
   .isLeftActive {
-    background-color: lightgrey;
+    background-color: #ededf5;
+  }
+  .left-list-item {
+    margin-bottom: 2px;
+  }
+  .left-list-item:hover {
+    background-color: #ededf5;
   }
 
   .light {
@@ -556,15 +593,17 @@
           border-radius: 10px;
           margin-top: 10px;
           padding: 10px;
-          height: 120px;
-          background-color: lightcyan;
-
+          min-height: 120px;
+          background-color: #e9f3ff;
+          .item-content {
+            color: #666;
+          }
           .item-title {
             text-align: center;
             line-height: 40px;
             font-size: 20px;
             font-family: 榛戜綋;
-            color: black;
+            color: #333;
           }
         }
       }
@@ -583,8 +622,16 @@
           flex: 1 1;
           flex-direction: column;
           overflow: hidden;
+          position: relative;
           :deep(.arco-textarea-wrapper) {
             border-radius: 24px;
+          }
+
+          .btn-send {
+            position: absolute !important;
+            right: 5px;
+            bottom: 5px;
+            z-index: 10;
           }
         }
       }
@@ -608,6 +655,12 @@
       }
       .right-tag {
         margin-top: 20px;
+        display: flex;
+        justify-content: space-between;
+        flex-wrap: wrap;
+        :deep(.arco-btn-size-mini.arco-btn-shape-round) {
+          margin-bottom: 10px !important;
+        }
       }
 
       .right-list {
@@ -615,15 +668,15 @@
           border-radius: 10px;
           margin-top: 10px;
           padding: 10px;
-          height: 120px;
-          background-color: lightcyan;
+          min-height: 120px;
+          background-color: #e9f3ff;
 
           .item-title {
             text-align: center;
             line-height: 40px;
             font-size: 20px;
             font-family: 榛戜綋;
-            color: black;
+            color: #333;
           }
         }
       }

--
Gitblit v1.8.0