From f1be1a3339bddda16aa7dfcef0ad4a55bddee2e2 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期二, 20 八月 2024 16:08:03 +0800
Subject: [PATCH] 聊天临时智能体默认图标修改

---
 src/views/sessionManager/components/historySession.vue |  153 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 127 insertions(+), 26 deletions(-)

diff --git a/src/views/sessionManager/components/historySession.vue b/src/views/sessionManager/components/historySession.vue
index 1fc2d03..24ef4e3 100644
--- a/src/views/sessionManager/components/historySession.vue
+++ b/src/views/sessionManager/components/historySession.vue
@@ -8,7 +8,7 @@
                 top: 10px;
                 left: -40px;
                 font-size: 30px;
-                z-index: 9999;
+                z-index: 99;
                 cursor: pointer"
                 @click="emit('changeAgentType','1')"
               >
@@ -18,9 +18,10 @@
               </a-button>
 
               <a-scrollbar
+                ref="scrollRef"
                 class="left-list"
                 style="
-                  height: calc(100vh - 100px);
+                  height: calc(100vh - 160px);
                   overflow-y: auto;
                   overflow-x: hidden;
                 "
@@ -47,31 +48,30 @@
                     class="item historyCenter-box"
                     v-for="session in sessionList"
                     @click="querySessionDetail(session)"
+                    @mouseenter="handleMouseEnter(session)"
+                    @mouseleave="handleMouseLeave(session)"
                   >
                     <div class="text" >
                       <img
                         :style="{ width: '16px' }"
                         alt="dessert"
-                        :src="session.avatar || imgSrc"
+                        :src="session.icon ? httpUrl + session.icon : imgSrc"
                       />
                       {{ session.name }}
                     </div>
-                    <a-popover position="rt">
-                      <div class="time"
-                      >{{
+                    <div class="time"
+                    >
+                      <span v-show="session.showtype == 1" style="font-size: 14px">
+                        {{
                           moment(new Date(session.create_time)).format(
                             'YYYY-MM-DD HH:mm:ss'
                           )
                         }}
-                      </div>
-                      <template #content>
-                        <span
-                          style="cursor: pointer; color: #4977ba; font-size: 12px"
-                          @click="deleteSession(session)"
-                        ><icon-delete style="font-size: 14px" />鍒犻櫎</span
-                        >
-                      </template>
-                    </a-popover>
+                      </span>
+                    </div>
+                    <a-button type="text" @click.stop="deleteSession(session)" style="color: red;position: absolute;right: 10px;top: 10px;"  v-show="session.showtype == 2">
+                      <icon-delete style="font-size: 14px" />
+                    </a-button>
                   </div>
                 </div>
               </a-scrollbar>
@@ -86,7 +86,7 @@
 import { useAppStore, useUserStore } from "@/store";
 import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue";
 
-import { Message } from "@arco-design/web-vue";
+import { Message, Modal } from "@arco-design/web-vue";
 import EventBus from '@/utils/EventBus';
 import moment from "moment";
 import {
@@ -95,12 +95,14 @@
   getDialogListApi,
   getSessionDetailsApi,
   deleteSessionApi,
-  sessionListApi
+  sessionListApiPage
 } from "@/api/session";
 
 import { queryCanvasList } from "@/api/Agent";
 const emit = defineEmits(["querySessionDetail","changeAgentType"]);
 import logo from "@/assets/images/model.png";
+import { deleteKnow } from "@/api/kbList";
+import { getAgentSessionDetailsApi } from "@/api/agentSession";
 const sessionList = ref([]); //浼氳瘽鍒楄〃
 const activeSessionId = ref("");
 const fieldNames = { value: "id", label: "name" };
@@ -111,6 +113,8 @@
 const searchValue = ref("");
 const selectValue = ref("");
 const sectionList = ref({});
+const scrollRef = ref(null);
+const httpUrl = localStorage.getItem('httpUrl');
 const imgSrc = ref(logo);
 const DialogList = async () => {
   const { code, data } = await getDialogListApi();
@@ -161,9 +165,18 @@
 
 // 鏌ヨ浼氳瘽鍒楄〃
 const querySessionList = async (id) => {
-  const { code, data } = await sessionListApi(id);
+  const { code, data } = await sessionListApiPage({
+    dialog_id: id,
+    page: 1,
+    page_size: 100
+  });
   if (code === 200) {
-    sessionList.value = data;
+    sessionList.value = data.map((item) => {
+      return {
+        ...item,
+        showtype: 1
+      }
+    });
 
 
 
@@ -174,18 +187,88 @@
 
 //鏍规嵁浼氳瘽id鍒犻櫎浼氳瘽
 const deleteSession = async (session) => {
-  const { code } = await deleteSessionApi([session.id]);
-  if (code === 200) {
-    Message.success('鍒犻櫎鎴愬姛');
-    querySessionList('');
-  }
+  Modal.confirm({
+    title: '鎻愮ず淇℃伅',
+    content: '纭鍒犻櫎鍚�',
+    okText: '纭畾',
+    cancelText: '鍙栨秷',
+    hideTitle: true,
+    onOk: async () => {
+      const { code } = await deleteSessionApi([session.id]);
+      if (code === 200) {
+        Message.success('鍒犻櫎鎴愬姛');
+        querySessionList('');
+      }
+    },
+    onCancel: () => {},
+  });
 };
 
 const querySessionDetail = async (session) => {
   console.log(session, 'session');
-  emit('changeAgentType','1');
-  emit('querySessionDetail',session);
+
+
+  // 鏌ヨ鍘嗗彶璁板綍
+  if (session.base == 'agent') {
+    // agent瀵硅薄鏁版嵁灏佽
+    // const { code, data } = await getAgentSessionDetailsApi(session.app_id);
+    // if (code == 0) {
+    //   console.log(data,'浼氳瘽璇︽儏');
+    //   let sessionObj = {
+    //     id: session.app_id,
+    //     dsl: data.dsl,
+    //     title: session.name,
+    //   }
+    //
+    // }
+    EventBus.emit("queryAgentSessionDetail",{
+      ...sessionObj,
+      id: session.app_id,
+    });
+    emit('changeAgentType','2');
+  } else {
+    // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
+    emit('changeAgentType','1');
+    emit('querySessionDetail',session);
+  }
+
+
+
 }
+
+
+const handleMouseEnter = (session) => {
+  session.showtype = 2;
+};
+
+const handleMouseLeave = (session) => {
+  session.showtype = 1;
+};
+
+
+const handleScroll = async (e: any) => {
+  // scrollTopVal.value = e.target.scrollTop
+  // let offsetHeight = e.target.offsetHeight
+  // let scrollHeight = e.target.scrollHeight
+  //
+  // if (scrollTopVal.value + offsetHeight >= scrollHeight) {
+  //   //婊氬姩鏉″埌杈惧簳閮�
+  //   if (cardData.value.length < total.value) {
+  //     //鏁版嵁涓哄姞杞藉畬锛岀户缁祴鍊�
+  //     serarchData.pageNum++
+  //
+  //
+  //
+  //   }
+  // }
+}
+
+const loading: any = computed(() => {
+  // cardData.value.length >= total.value
+})
+
+
+
 onBeforeMount(()=>{
   // DialogList()
   querySessionList('');
@@ -198,6 +281,23 @@
     querySessionList('');
 
   });
+
+//   缁欏厓绱犳坊鍔犳粴鍔ㄤ簨浠剁洃鍚�
+//   if (scrollRef.value) {
+//     // 缁欏厓绱犳坊鍔犳粴鍔ㄧ洃鍚櫒
+//
+//     scrollRef.value.addEventListener('scroll', handleScroll, true)
+//
+//     // 濡傛灉浣犻渶瑕佸湪缁勪欢鍗歌浇鏃剁Щ闄ょ洃鍚櫒锛屽彲浠ヨ繑鍥炰竴涓竻鐞嗗嚱鏁�
+//     return () => {
+//       scrollRef.value.removeEventListener('scroll', handleScroll, true)
+//     }
+//   }
+
+
+
+
+
 })
 onBeforeUnmount(() => {
   EventBus.off("history");
@@ -239,6 +339,7 @@
       width: 100%;
       margin-top: 30px;
       .historyCenter-box{
+        position: relative;
         display: flex;
         width: 70%;
         margin-left: 15%;

--
Gitblit v1.8.0