| | |
| | | top: 10px; |
| | | left: -40px; |
| | | font-size: 30px; |
| | | z-index: 9999; |
| | | z-index: 99; |
| | | cursor: pointer" |
| | | @click="emit('changeAgentType','1')" |
| | | > |
| | |
| | | </a-button> |
| | | |
| | | <a-scrollbar |
| | | ref="scrollRef" |
| | | class="left-list" |
| | | style=" |
| | | height: calc(100vh - 100px); |
| | | overflow-y: auto; |
| | | height: calc(100vh - 160px); |
| | | overflow-y: scroll; |
| | | overflow-x: hidden; |
| | | " |
| | | v-if="isReached" |
| | | @scroll="handleScroll" |
| | | > |
| | | <div class="historyTitle___F_iam">历史会话</div> |
| | | |
| | |
| | | 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> |
| | | <div class="time" |
| | | >{{ |
| | | moment(new Date(session.create_time)).format( |
| | | 'YYYY-MM-DD HH:mm:ss' |
| | | ) |
| | | }} |
| | | > |
| | | <span v-show="session.showtype == 1" style="font-size: 14px"> |
| | | {{ |
| | | moment(new Date(session.create_time)).format( |
| | | 'YYYY-MM-DD HH:mm:ss' |
| | | ) |
| | | }} |
| | | </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> |
| | |
| | | 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 { |
| | |
| | | chatApi, |
| | | getDialogListApi, |
| | | getSessionDetailsApi, |
| | | sessionListApi |
| | | deleteSessionApi, |
| | | 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" }; |
| | |
| | | const searchValue = ref(""); |
| | | const selectValue = ref(""); |
| | | const sectionList = ref({}); |
| | | const scrollRef = ref(null); |
| | | const httpUrl = localStorage.getItem('httpUrl'); |
| | | const imgSrc = ref(logo); |
| | | let scrollTopVal = ref(0); |
| | | let queryPage = reactive({ |
| | | page: 1, |
| | | page_size: 50 |
| | | }) |
| | | let total = ref(0); |
| | | let sessionScrollList = ref([]); |
| | | let isReached = ref(true); |
| | | |
| | | const DialogList = async () => { |
| | | const { code, data } = await getDialogListApi(); |
| | | if (code === 200) { |
| | |
| | | |
| | | // 查询会话列表 |
| | | const querySessionList = async (id) => { |
| | | const { code, data } = await sessionListApi(id); |
| | | const { code, data } = await sessionListApiPage({ |
| | | dialog_id: id, |
| | | ...queryPage |
| | | }); |
| | | if (code === 200) { |
| | | sessionList.value = data; |
| | | |
| | | sessionList.value = data.map((item) => { |
| | | return { |
| | | ...item, |
| | | showtype: 1 |
| | | } |
| | | }); |
| | | isReached.value = false; |
| | | setTimeout(()=>{ |
| | | isReached.value = true; |
| | | },100) |
| | | // total.value = sessionList.value.length; |
| | | |
| | | |
| | | } else { |
| | |
| | | } |
| | | }; |
| | | |
| | | //根据会话id删除会话 |
| | | const deleteSession = async (session) => { |
| | | 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); |
| | | // 查询历史记录 app_type 1:智能体 2:agent |
| | | if (session.app_type == '1') { |
| | | // 生成智能体新的对话 |
| | | emit('changeAgentType','1'); |
| | | emit('querySessionDetail',session); |
| | | } else if (session.app_type == '2'){ |
| | | // agent对象数据封装 |
| | | // const { code, data } = await getAgentSessionDetailsApi(session.dialog_id); |
| | | // if (code == 0) { |
| | | // console.log(data,'会话详情'); |
| | | // // let sessionObj = { |
| | | // // id: session.app_id, |
| | | // // dsl: data.dsl, |
| | | // // title: session.name, |
| | | // // } |
| | | // } |
| | | EventBus.emit("queryAgentSessionDetail",session); |
| | | emit('changeAgentType','2'); |
| | | } |
| | | } |
| | | |
| | | |
| | | 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-1) { |
| | | console.log(scrollTopVal.value); |
| | | // console.log(offsetHeight); |
| | | // console.log(scrollHeight); |
| | | //滚动条到达底部 |
| | | // if (sessionList.value.length < total.value) { |
| | | // //数据为加载完,继续赋值 |
| | | // // queryPage.page++ |
| | | // |
| | | // |
| | | // |
| | | // } |
| | | queryPage.page++ |
| | | const { code, data } = await sessionListApiPage({ |
| | | dialog_id: '', |
| | | ...queryPage |
| | | }); |
| | | if (code === 200) { |
| | | sessionScrollList.value = data.map((item) => { |
| | | return { |
| | | ...item, |
| | | showtype: 1 |
| | | } |
| | | }); |
| | | // total.value = sessionList.value.length; |
| | | sessionList.value = [...sessionList.value,...sessionScrollList.value]; |
| | | isReached.value = false; |
| | | setTimeout(()=>{ |
| | | isReached.value = true; |
| | | nextTick(()=>{ |
| | | scrollRef.value.scrollTop(scrollTopVal.value); |
| | | // console.log(scrollRef.value.$el.scrollTop,'scrollTopVal'); |
| | | // console.log(scrollTopVal.value,'scrollTopVal'); |
| | | }) |
| | | },100) |
| | | |
| | | |
| | | } else { |
| | | Message.warning("查询失败"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | onBeforeMount(()=>{ |
| | | DialogList() |
| | | // DialogList() |
| | | querySessionList(''); |
| | | }) |
| | | |
| | | onMounted(() => { |
| | | EventBus.on("history", () => { |
| | | emit('changeAgentType','3'); |
| | | DialogList() |
| | | // DialogList() |
| | | queryPage.page = 1; |
| | | querySessionList(''); |
| | | |
| | | }); |
| | | // 添加滚动事件监听器 |
| | | scrollRef.value.$el.addEventListener('scroll', handleScroll); |
| | | |
| | | // 清理函数 |
| | | return () => { |
| | | scrollRef.value.$el.removeEventListener('scroll', handleScroll); |
| | | }; |
| | | |
| | | |
| | | |
| | | }) |
| | | onBeforeUnmount(() => { |
| | | EventBus.off("history"); |
| | |
| | | width: 100%; |
| | | margin-top: 30px; |
| | | .historyCenter-box{ |
| | | position: relative; |
| | | display: flex; |
| | | width: 70%; |
| | | margin-left: 15%; |