From b3b34fa409762b44e6fd3c89e651f8c465556a48 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期五, 23 八月 2024 19:25:05 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/web/flow_web

---
 src/views/sessionManager/index.vue |  147 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 110 insertions(+), 37 deletions(-)

diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue
index 3404ffb..31bb72c 100644
--- a/src/views/sessionManager/index.vue
+++ b/src/views/sessionManager/index.vue
@@ -24,7 +24,13 @@
 
                 <a-popover position="bottom" trigger="click">
                   <a-button border
-                    >{{ agentTitle }}
+                    >
+                    <span style="
+                       width: 100px;
+                      overflow: hidden;
+                      text-overflow: ellipsis;
+                      white-space: nowrap;
+                    ">{{ from.name }}</span>
                     <icon-down style="margin-left: 4px" />
                   </a-button>
                   <template #content>
@@ -227,8 +233,27 @@
                   maxRows: 5,
                 }"
               />
-
-              <div class="btn-send">
+              <div style="width: 100%;display: flex;justify-content: space-between">
+                <a-button
+                  :disabled="onFileSelectedLoading"
+                  @click="selectFile"
+                  type="text"
+                  style="border-radius: 24px"
+                >
+                  <icon-attachment
+                    size="28"
+                    style="color: #0960bd"
+                  />
+                  <input
+                    ref="fileInput"
+                    type="file"
+                    style="display: none"
+                    @change="onFileSelected"
+                  />
+                </a-button>
+                  <span
+                    style="cursor: pointer;margin-left: 20px;">
+                </span>
                 <a-button
                   :disabled="chatDis"
                   @click="sentClick"
@@ -239,6 +264,17 @@
                   <icon-send size="32" style="color: #0960bd" />
                 </a-button>
               </div>
+<!--              <div class="btn-send">-->
+<!--                <a-button-->
+<!--                  :disabled="chatDis"-->
+<!--                  @click="sentClick"-->
+<!--                  type="text"-->
+<!--                  style="border-radius: 24px"-->
+<!--                  :loading="loading"-->
+<!--                >-->
+<!--                  <icon-send size="32" style="color: #0960bd" />-->
+<!--                </a-button>-->
+<!--              </div>-->
             </div>
             <!--            <div style="margin-top: 0px">-->
             <!--              <a-upload-->
@@ -253,27 +289,27 @@
             <!--                </template>-->
             <!--              </a-upload>-->
             <!--            </div>-->
-            <span
-              style="
-                position: absolute;
-                top: 94px;
-                left: 20px;
-                z-index: 999;
-                cursor: pointer;
-              "
-            >
-              <icon-attachment
-                size="28"
-                @click="selectFile"
-                style="color: #0960bd"
-              />
-              <input
-                ref="fileInput"
-                type="file"
-                style="display: none"
-                @change="onFileSelected"
-              />
-            </span>
+<!--            <span-->
+<!--              style="-->
+<!--                position: absolute;-->
+<!--                top: 94px;-->
+<!--                left: 20px;-->
+<!--                z-index: 999;-->
+<!--                cursor: pointer;-->
+<!--              "-->
+<!--            >-->
+<!--              <icon-attachment-->
+<!--                size="28"-->
+<!--                @click="selectFile"-->
+<!--                style="color: #0960bd"-->
+<!--              />-->
+<!--              <input-->
+<!--                ref="fileInput"-->
+<!--                type="file"-->
+<!--                style="display: none"-->
+<!--                @change="onFileSelected"-->
+<!--              />-->
+<!--            </span>-->
             <div class="uploadFileList">
               <div
                 class="files"
@@ -283,11 +319,12 @@
               >
                 <a-comment
                   :author="item.name"
-                  :content="item.size + ''"
+                  :content="(item.size/1024).toFixed(2) + 'K'"
                   style="
                     background: var(--color-bg-2);
                     padding: 10px;
                     border-radius: 10px;
+                    font-size: 12px;
                   "
                 >
                   <template #avatar>
@@ -355,11 +392,11 @@
       <a-form
         ref="formRef"
         :rules="rules"
-        :model="chatObj"
+        :model="from"
         @submit="handleSubmit"
       >
         <a-form-item field="name" label="鍚嶇О">
-          <a-input v-model="agentTitle" placeholder="璇疯緭鍏ュ悕绉�" />
+          <a-input v-model="from.name" placeholder="璇疯緭鍏ュ悕绉�" />
         </a-form-item>
         <a-form-item>
           <div style="width: 100%; text-align: right">
@@ -434,6 +471,9 @@
   const agentType = ref('1');
   const agentTitle = ref('鏈懡鍚嶄細璇�');
   let chatObj = reactive({});
+  let from = reactive({
+    name:'鏈懡鍚嶄細璇�',
+  });
   const isStopChat = ref(false);
   const currIndex = ref(0);
   const displayedText = ref(''); // 姝e湪鏄剧ず鐨勬枃瀛�
@@ -456,6 +496,7 @@
   const fileInput = ref(null);
   const chatDataMeg = reactive({});
   const visible = ref(false);
+  let toStop = false;
 
   const rules = {
     name: [
@@ -468,12 +509,10 @@
 
   const handleSubmit = async ({ values, errors }) => {
     if (errors) return;
-    // chatObj.name = agentTitle.value;
-    // chatObj.conversation_id = chatObj.id;
     let chatData = {
       id: chatObj.id,
       conversation_id: chatObj.id,
-      name: agentTitle.value,
+      name: from.name,
     };
     const { code, data } = await addSessionApi(chatData);
     if (data) {
@@ -484,13 +523,10 @@
   };
   let dataItem = [];
   const getTxt = (data, role, message, index) => {
-    if (/##0\$\$/.test(message)) {
+    if (/##[0-9]\$\$/.test(message)) {
       if (role == 'assistant' && index) {
-        data.forEach((item) => {
-          if (Object.keys(item).length !== 0 && item?.doc_aggs.length > 0) {
-            dataItem = item.doc_aggs;
-          }
-        });
+        let i = index / 2 - 1 > 0 ? index / 2 - 1 : 0;
+        dataItem = data[i].doc_aggs;
       }
     } else {
       dataItem = [];
@@ -501,7 +537,35 @@
 
   const clickHref = (item) => {
     // return Message.warning('鏆傛棤娉曟煡鐪�');
-    window.open(`/api/v1/document/show/${item.doc_id}`, '_blank');
+    // window.open(`/api/v1/document/get/${item.doc_id}`, '_blank');
+    downloadFile({
+      url: `/api/v1/document/get/${item.doc_id}`,
+      filename: item.doc_name,
+    });
+  };
+
+   const downloadFile = ({
+                                 url,
+                                 filename,
+                                 target,
+                               }: {
+    url: string;
+    filename?: string;
+    target?: string;
+  }) => {
+    const downloadElement = document.createElement('a');
+    downloadElement.style.display = 'none';
+    downloadElement.href = url;
+    if (target) {
+      downloadElement.target = '_blank';
+    }
+    downloadElement.rel = 'noopener noreferrer';
+    if (filename) {
+      downloadElement.download = filename;
+    }
+    document.body.appendChild(downloadElement);
+    downloadElement.click();
+    document.body.removeChild(downloadElement);
   };
 
   const getIconByExtension = computed(() => (extension) => {
@@ -740,6 +804,7 @@
   const startChat = async (valMsg) => {
     chatDis.value = true;
     loading.value = true;
+    toStop = false;
     sessionDetailList.value.push({
       content: valMsg,
       role: 'user',
@@ -767,6 +832,11 @@
       .getReader();
     currIndex.value = 0;
     while (true) {
+      if (toStop) {
+        displayedText.value = '';
+        setChatDataMeg(chatDataMeg);
+        break;
+      }
       const x = await reader?.read();
       if (x) {
         const { done, value } = x;
@@ -809,6 +879,7 @@
     loading.value = false;
     chatDis.value = false;
     isStopChat.value = true;
+    toStop = true;
     console.log('stopChat');
     console.log(displayedText.value, 'displayedText');
     console.log(sessionDetailList.value, 'sessionDetailList');
@@ -859,6 +930,7 @@
       sessionDetailList.value = data.message;
       messagenList.value = data;
       agentTitle.value = data.name;
+      from.name = data.name;
       refreshScroll(); //鍒锋柊婊氬姩鏉′綅缃�
       isStopChat.value = false;
     }
@@ -872,6 +944,7 @@
   const querySessionDetail = async (session) => {
     sectionList.value = session;
     activeSessionId.value = session.id;
+    from.name = session.name;
     const { code, data } = await getSessionDetailsApi(session.id);
     if (code === 200) {
       sessionDetailList.value = data.message;

--
Gitblit v1.8.0