liudong
2024-08-20 f1be1a3339bddda16aa7dfcef0ad4a55bddee2e2
src/views/sessionManager/components/historySession.vue
@@ -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;
                "
@@ -54,7 +55,7 @@
                      <img
                        :style="{ width: '16px' }"
                        alt="dessert"
                        :src="session.avatar || imgSrc"
                        :src="session.icon ? httpUrl + session.icon : imgSrc"
                      />
                      {{ session.name }}
                    </div>
@@ -94,13 +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,7 +165,11 @@
// 查询会话列表
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.map((item) => {
      return {
@@ -198,8 +206,34 @@
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);
  }
}
@@ -210,6 +244,30 @@
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()
@@ -223,6 +281,23 @@
    querySessionList('');
  });
//   给元素添加滚动事件监听
//   if (scrollRef.value) {
//     // 给元素添加滚动监听器
//
//     scrollRef.value.addEventListener('scroll', handleScroll, true)
//
//     // 如果你需要在组件卸载时移除监听器,可以返回一个清理函数
//     return () => {
//       scrollRef.value.removeEventListener('scroll', handleScroll, true)
//     }
//   }
})
onBeforeUnmount(() => {
  EventBus.off("history");