src/views/sessionManager/components/chatMenu.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/sessionManager/components/historySession.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/sessionManager/components/smartAi.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/sessionManager/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/sessionManager/style/layout.css | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/views/sessionManager/components/chatMenu.vue
@@ -4,22 +4,28 @@ <div class="myAgent___djnd_ myAgentAnim myAgentlight___yK7Gk"> <!-- <div data-testid="msh-sidebar-main" class="myAgentHome___PG6IZ"></div>--> <div class="myAgentLine___Isl6E"></div> <div class="myAgentTool___Y1_mC" data-testid="msh-sidebar-new"> <div class="myAgentTool___Y1_mC" data-testid="msh-sidebar-new" @click="()=>{ EventBus.emit('newChat') }"> <div class="myAgentToolIcon___gaAKI myAgentToolIconNew___DBZrW"> <img src="../../../assets/images/talkbg.svg" style="width: 24px" alt=""></div> </div> <div data-testid="msh-sidebar-history" class="myAgentTool___Y1_mC"> <div class="myAgentToolIcon___gaAKI myAgentToolIconHistory___GTLWk"> <div data-testid="msh-sidebar-history" class="myAgentTool___Y1_mC" @click="()=>{ EventBus.emit('history') }"> <div class="myAgentToolIcon___gaAKI myAgentToolIconHistory___GTLWk" > <img src="../../../assets/images/history.svg" style="width: 24px" alt=""> </div> </div> <div data-testid="msh-sidebar-square" class="myAgentTool___Y1_mC myAgentToolSquare___dbLm1"> <div data-testid="msh-sidebar-square" class="myAgentTool___Y1_mC myAgentToolSquare___dbLm1" @click="()=>{ EventBus.emit('smartAi') }"> <div class="myAgentToolIcon___gaAKI myAgentToolIconSquare___Rj1o_"><img src="../../../assets/images/agentbg.svg" style="width: 24px" @@ -101,13 +107,7 @@ import { computed, nextTick, onMounted, watch, reactive, ref } from "vue"; import { Message } from "@arco-design/web-vue"; import { EventSourceParserStream } from "eventsource-parser/stream"; import { chatApi, getDialogListApi, getSessionDetailsApi, sessionListApi } from "@/api/session"; import EventBus from '@/utils/EventBus'; </script> <style scoped lang="less"> src/views/sessionManager/components/historySession.vue
New file @@ -0,0 +1,248 @@ <template> <div class="layoutHisCenter"> <a-button type="primary" status="danger" style=" position: absolute; top: 10px; left: -40px; font-size: 30px; z-index: 9999; cursor: pointer" @click="emit('changeAgentType','1')" > <template #icon> <icon-close style="font-size: 20px" /> </template> </a-button> <a-scrollbar class="left-list" style=" height: calc(100vh - 100px); overflow-y: auto; overflow-x: hidden; " > <div class="historyTitle___F_iam">历史会话</div> <div class="search"> <!-- 查询框--> <div class="search-box"> <icon-search /> <a-input placeholder="搜索历史会话" v-model="searchValue" style="width: 90%;" /> </div> </div> <div class="historyCenter"> <div class="item historyCenter-box" v-for="session in sessionList" @click="querySessionDetail(session)" > <div class="text" > <img :style="{ width: '16px' }" alt="dessert" :src="session.avatar || imgSrc" /> {{ session.name }} </div> <div class="time" >{{ moment(new Date(session.create_time)).format( 'YYYY-MM-DD HH:mm:ss' ) }} </div> </div> </div> </a-scrollbar> </div> </template> <script setup lang="ts"> import { IconClose, IconSearch, IconTiktokColor } from "@arco-design/web-vue/es/icon"; import { useAppStore, useUserStore } from "@/store"; import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue"; import { Message } from "@arco-design/web-vue"; import EventBus from '@/utils/EventBus'; import moment from "moment"; import { addSessionApi, chatApi, getDialogListApi, getSessionDetailsApi, sessionListApi } from "@/api/session"; import { queryCanvasList } from "@/api/Agent"; const emit = defineEmits(["querySessionDetail","changeAgentType"]); import logo from "@/assets/images/model.png"; const sessionList = ref([]); //会话列表 const activeSessionId = ref(""); const fieldNames = { value: "id", label: "name" }; const dialogs = ref([]); const dialogObj = reactive({}); const agentObj = reactive({}); const agentList = ref([]); const searchValue = ref(""); const selectValue = ref(""); const sectionList = ref({}); const imgSrc = ref(logo); const DialogList = async () => { const { code, data } = await getDialogListApi(); if (code === 200) { if (data) { selectValue.value = data[0].id; dialogs.value = data.map((item) => { return { ...item, type: 1 //智能体 }; }); // console.log(data, "dialogs"); queryCanvas(); } } }; const queryCanvas = async (params = {}) => { try { const { data } = await queryCanvasList(params); console.log(data, "agent"); agentList.value = data.map((item) => { return { ...item, name: item.title, type: 2 //agent }; }); // 合并数组 dialogs.value = dialogs.value.concat(agentList.value); // 判断当前是智能体或agent // console.log(val, 'val'); // if (dialogs.value.length > 0) { // dialogChange(dialogs.value[0].id); // } //新建会话 querySessionList(dialogs.value[0].id); } catch (err) { // you can report use errorHandler or other } finally { } }; // 查询会话列表 const querySessionList = async (id) => { const { code, data } = await sessionListApi(id); if (code === 200) { sessionList.value = data; } else { Message.warning("查询失败"); } }; const querySessionDetail = async (session) => { console.log(session, 'session'); emit('changeAgentType','1'); emit('querySessionDetail',session); } onBeforeMount(()=>{ DialogList() }) onMounted(() => { EventBus.on("history", () => { emit('changeAgentType','3'); DialogList() }); }) onBeforeUnmount(() => { EventBus.off("history"); }); </script> <style scoped lang="less"> .layoutHisCenter{ width: 100%; //background: #999999; position: absolute; left: 0; top: 0; .historyTitle___F_iam { font-size: 36px; line-height: 50px; font-weight: 700; text-align: center; } .search{ width: 100%; .search-box{ width: 70%; margin-left: 15%; border: 1px solid var(--color-text-4); padding: 10px; border-radius: 12px; background: var(--color-bg-2); margin-top: 20px; margin-bottom: 20px; :deep(.arco-input-wrapper){ border: none; background: var(--color-bg-2); } } } .historyCenter{ width: 100%; margin-top: 30px; .historyCenter-box{ display: flex; width: 70%; margin-left: 15%; //border: 1px solid var(--color-text-4); padding: 16px; border-radius: 12px; background: var(--color-bg-2); margin-top: 10px; cursor: pointer; justify-content: space-between; align-items: center; } .historyCenter-box:hover{ color: #2a2a2b; border: 1px solid var(--color-neutral-3); //background: #e8e8ea; box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09); } } } </style> src/views/sessionManager/components/smartAi.vue
New file @@ -0,0 +1,201 @@ <template> <div class="layoutHisCenter"> <a-scrollbar class="left-list" style=" height: calc(100vh - 100px); overflow-y: auto; overflow-x: hidden; " > <div class="historyCenter"> <div class="item historyCenter-box" v-for="item in dialogs" @click="querySessionDetail(item)" > <div class="text" > <img :style="{ width: '16px' }" alt="dessert" :src="item.avatar || imgSrc" /> {{ item.name }} </div> <div class="time" > </div> </div> </div> </a-scrollbar> </div> </template> <script setup lang="ts"> import { IconClose, IconSearch, IconTiktokColor } from "@arco-design/web-vue/es/icon"; import { useAppStore, useUserStore } from "@/store"; import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue"; import { Message } from "@arco-design/web-vue"; import EventBus from '@/utils/EventBus'; import moment from "moment"; import { addSessionApi, chatApi, getDialogListApi, getSessionDetailsApi, sessionListApi } from "@/api/session"; import { queryCanvasList } from "@/api/Agent"; const emit = defineEmits(["querySessionDetail","changeAgentType"]); import logo from "@/assets/images/model.png"; const sessionList = ref([]); //会话列表 const activeSessionId = ref(""); const fieldNames = { value: "id", label: "name" }; const dialogs = ref([]); const dialogObj = reactive({}); const agentObj = reactive({}); const agentList = ref([]); const searchValue = ref(""); const selectValue = ref(""); const sectionList = ref({}); const imgSrc = ref(logo); const DialogList = async () => { const { code, data } = await getDialogListApi(); if (code === 200) { if (data) { selectValue.value = data[0].id; dialogs.value = data.map((item) => { return { ...item, type: 1 //智能体 }; }); // console.log(data, "dialogs"); queryCanvas(); } } }; const queryCanvas = async (params = {}) => { try { const { data } = await queryCanvasList(params); console.log(data, "agent"); agentList.value = data.map((item) => { return { ...item, name: item.title, type: 2 //agent }; }); // 合并数组 dialogs.value = dialogs.value.concat(agentList.value); } catch (err) { // you can report use errorHandler or other } finally { } }; // 查询会话列表 const querySessionList = async (id) => { const { code, data } = await sessionListApi(id); if (code === 200) { sessionList.value = data; } else { Message.warning("查询失败"); } }; const querySessionDetail = async (session) => { console.log(session, 'session'); emit('changeAgentType','1'); emit('querySessionDetail',session); } onBeforeMount(()=>{ DialogList() }) onMounted(() => { EventBus.on("smartAi", () => { emit('changeAgentType','4'); DialogList() }); }) onBeforeUnmount(() => { EventBus.off("smartAi"); }); </script> <style scoped lang="less"> .layoutHisCenter{ width: 100%; //background: #999999; position: absolute; left: 0; top: 0; .historyTitle___F_iam { font-size: 36px; line-height: 50px; font-weight: 700; text-align: center; } .search{ width: 100%; .search-box{ width: 70%; margin-left: 15%; border: 1px solid var(--color-text-4); padding: 10px; border-radius: 12px; background: var(--color-bg-2); margin-top: 20px; margin-bottom: 20px; :deep(.arco-input-wrapper){ border: none; background: var(--color-bg-2); } } } .historyCenter{ width: 100%; margin-top: 30px; .historyCenter-box{ display: flex; width: 70%; margin-left: 15%; //border: 1px solid var(--color-text-4); padding: 16px; border-radius: 12px; background: var(--color-bg-2); margin-top: 10px; cursor: pointer; justify-content: space-between; align-items: center; } .historyCenter-box:hover{ color: #2a2a2b; border: 1px solid var(--color-neutral-3); //background: #e8e8ea; box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09); } } } </style> src/views/sessionManager/index.vue
@@ -1,10 +1,10 @@ <template> <div class="container"> <AddSession :modalObj="modalObj" @addSession="addSession" :dialogId="dialogId" ></AddSession> <!-- <AddSession--> <!-- :modalObj="modalObj"--> <!-- @addSession="addSession"--> <!-- :dialogId="dialogId"--> <!-- ></AddSession>--> <!-- <a-card class="top-title">AI会话记录</a-card>--> <a-row :gutter="[5, 5]" style="margin-top: 3px;"> <!-- <a-col :span="6">--> @@ -68,83 +68,14 @@ </a-col> <!-- 智能体会话--> <a-col :span="23" v-show="agentType == '1'"> <!-- <div v-if="sessionDetailList.length === 0" style=" width: 90%; overflow: auto; height: 65vh; margin: 0px auto 20px; " > <div class="center-title">智能问答</div> <div class="center-content"> 我可以理解和学习人类的语言,具备多轮对话的能力,现在和我开始交流吧~ </div> <div class="center-question"> <div class="center-question-left">试一试这样问我</div> <div class="center-question-right"> <a-button type="primary">换一换</a-button> <div class="center"> <div class="header___lEPyH"> <div class="chatHeader"> <div class="chatHeaderBox"> <span class="title">{{agentTitle}}</span> </div> </div> </div> <a-row justify="space-around" class="center-list"> <a-col :span="7" class="item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </a-col> <a-col :span="7" class="item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </a-col> <a-col :span="7" class="item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </a-col> <a-col :span="7" class="item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </a-col> <a-col :span="7" class="item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </a-col> <a-col :span="7" class="item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </a-col> </a-row> </div> --> <div class="center"> <a-scrollbar ref="scrollbar" id="home" @@ -259,67 +190,16 @@ <agentSession :modalObj="agentObj"></agentSession> </div> </a-col> <!-- <a-col :span="5"> <a-card class="right"> <div class="right-top"> <div class="right-title">数智库</div> <div class="right-btn"> <a-button type="outline" shape="circle" style="border: none"> <icon-search /> </a-button> <a-button type="outline" shape="circle" style="border: none; margin-left: -10px" > <icon-close /> </a-button> </div> </div> <div class="right-tag"> <a-button type="primary" size="mini" class="btn">全部 </a-button> <a-button type="outline" size="mini" class="btn" >文档创作 </a-button> <a-button type="outline" size="mini" class="btn" >知识学习 </a-button> <a-button type="outline" size="mini" class="btn" >效率提升 </a-button> </div> <div class="right-list"> <div class="right-item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </div> <div class="right-item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </div> <div class="right-item"> <div class="item-title"> <IconTiktokColor></IconTiktokColor> 抖音带货脚本 </div> <div class="item-content" :class="{ dark: theme === 'dark' }"> 编写引人注目且具有说服力的、适用于产品的... </div> </div> </div> </a-card> </a-col> --> <a-col :span="23" v-show="agentType == '3'"> <div class="center" style="padding: 0"> <historySession @querySessionDetail="querySessionDetail" @changeAgentType="changeAgentType"></historySession> </div> </a-col> <a-col :span="23" v-show="agentType == '4'"> <div class="center" style="padding: 0"> <smartAi @querySessionDetail="querySessionDetail" @changeAgentType="changeAgentType"></smartAi> </div> </a-col> </a-row> </div> </template> @@ -330,7 +210,7 @@ IconTiktokColor } from "@arco-design/web-vue/es/icon"; import { useAppStore, useUserStore } from "@/store"; import { computed, nextTick, onMounted, watch, reactive, ref } from "vue"; import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue"; import { Message } from "@arco-design/web-vue"; import { EventSourceParserStream } from "eventsource-parser/stream"; @@ -338,7 +218,11 @@ import chatMenu from "@/views/sessionManager/components/chatMenu.vue"; import AddSession from "@/views/sessionManager/components/addSession.vue"; import agentSession from "@/views/sessionManager/components/agentSession.vue"; import historySession from "@/views/sessionManager/components/historySession.vue"; import smartAi from "@/views/sessionManager/components/smartAi.vue"; import EventBus from "@/utils/EventBus"; import { addSessionApi, chatApi, getDialogListApi, getSessionDetailsApi, @@ -355,6 +239,7 @@ const chatDis = ref(false); const loading = ref(false); const agentType = ref("1"); const agentTitle = ref("未命名会话"); const currIndex = ref(0); const displayedText = ref(""); // 正在显示的文字 @@ -382,7 +267,6 @@ }); console.log(data, "dialogs"); queryCanvas(); // querySessionList(); } } }; @@ -403,14 +287,35 @@ // 判断当前是智能体或agent // console.log(val, 'val'); if (dialogs.value.length > 0) { dialogChange(dialogs.value[0].id); } // if (dialogs.value.length > 0) { // dialogChange(dialogs.value[0].id); // } //新建会话 createSession(dialogs.value[0].id); } catch (err) { // you can report use errorHandler or other } finally { } }; // 新建会话 const createSession = async (id) => { const res = await addSessionApi({ dialog_id: id, conversation_desc: "未命名会话" }); console.log(res, "res"); if (res.code == 200) { // console.log(res.data.conversation_id); activeSessionId.value = res.data?.conversation_id; queryNewSessionDetail(res.data?.conversation_id); } else { Message.error("创建会话失败,请重试"); } }; const handleShiftEnter = (event) => { event.preventDefault(); @@ -506,12 +411,12 @@ if (done) { console.info("done"); displayedText.value = ""; querySessionDetail(sectionList.value); queryNewSessionDetail(activeSessionId.value); break; } } } querySessionList(); // querySessionList(); chatDis.value = false; loading.value = false; inputMsg.value = ""; @@ -523,6 +428,22 @@ } } }; const queryNewSessionDetail = async (id) => { activeSessionId.value = id; const { code, data } = await getSessionDetailsApi(id); if (code === 200) { sessionDetailList.value = data.message; agentTitle.value = data.name; refreshScroll(); //刷新滚动条位置 } }; const changeAgentType = (val,session) => { agentType.value = val; console.log(val, "val"); } const querySessionDetail = async (session) => { sectionList.value = session; activeSessionId.value = session.id; @@ -574,8 +495,17 @@ const addSession = () => { querySessionList(); }; onMounted(() => { onBeforeMount(() => { DialogList(); }); onMounted(() => { EventBus.on("newChat", () => { agentType.value = 1; createSession(dialogs.value[0].id); }); }); onBeforeUnmount(() => { EventBus.off("newChat"); }); const appStore = useAppStore(); @@ -694,6 +624,7 @@ .center { position: relative; padding-left: 50px; .center-title { line-height: 60px; @@ -862,4 +793,22 @@ } } } .header___lEPyH { width: 100%; height: 46px; position: relative; backdrop-filter: blur(15px); display: flex; align-items: center; justify-content: center; -webkit-backdrop-filter: blur(15px); .chatHeaderBox { width: auto; border-radius: 8px; padding: 4px 20px; transition: all var(--animation-duration) var(--animation-transition); display: flex; align-items: flex-end; } } </style> src/views/sessionManager/style/layout.css
@@ -1395,7 +1395,7 @@ .myAgentLine___Isl6E { width: 24px; height: 1px; background-color: #ece7e7; background-color: #f0f0f0; border-radius: 12px; margin-bottom: 16px; cursor: pointer @@ -1438,7 +1438,7 @@ height: 28px; line-height: 28px; text-align: center; content: "\5f00\542f\65b0\4f1a\8bdd"; content: "开启新会话"; position: absolute; left: 54px; display: none; @@ -1475,7 +1475,7 @@ height: 28px; line-height: 28px; text-align: center; content: "\5386\53f2\4f1a\8bdd"; content: "历史会话"; position: absolute; left: 54px; display: none; @@ -1508,11 +1508,11 @@ } .myAgent___djnd_ .myAgentTool___Y1_mC .myAgentToolIconSquare___Rj1o_:after { width: 58px; width: 70px; height: 28px; line-height: 28px; text-align: center; content: "Kimi+"; content: "SmartAl+"; position: absolute; left: 54px; display: none;