From 21b287fe2f72d4a228e22b495cd77ce45956dfd2 Mon Sep 17 00:00:00 2001 From: han2015 <1019850453@qq.com> Date: Sat, 11 Oct 2025 11:46:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E4=BD=93=EF=BC=9A=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BC=9A=E8=AF=9D=E5=88=86=E4=BA=AB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/doc/space.ts | 25 ++++++ src/views/common/bottom/FloatingBall.vue | 2 +- src/views/doc/agent.vue | 98 +++++++++++++++++++++--- src/views/doc/manage.vue | 2 +- 4 files changed, 115 insertions(+), 12 deletions(-) diff --git a/src/api/doc/space.ts b/src/api/doc/space.ts index 73630ae..d961feb 100644 --- a/src/api/doc/space.ts +++ b/src/api/doc/space.ts @@ -211,6 +211,31 @@ export function setAiChat(data: any){ }); } +/** + * 更新会话 + * @requires key + * + */ +export function getShareChat(key: string){ + return request({ + url: '/aibot/chat/shared/'+key, + method: 'get', + }); +} + +/** + * 更新会话 + * @requires key agentID+chatID+index + * @requires data + */ +export function newShareChat(data: any){ + return request({ + url: '/aibot/chat/share', + method: 'post', + data: data + }); +} + /** * 获取智能体 */ diff --git a/src/views/common/bottom/FloatingBall.vue b/src/views/common/bottom/FloatingBall.vue index 7d491ef..72361dc 100644 --- a/src/views/common/bottom/FloatingBall.vue +++ b/src/views/common/bottom/FloatingBall.vue @@ -5,7 +5,7 @@ import { ref, computed } from 'vue' const emit = defineEmits(['click']) const x = ref(window.innerWidth - 60) -const y = ref(window.innerHeight - 150) +const y = ref(window.innerHeight - 250) const isDragging = ref(false) const ballStyle = computed(() => ({ diff --git a/src/views/doc/agent.vue b/src/views/doc/agent.vue index 5b3e243..3849d89 100644 --- a/src/views/doc/agent.vue +++ b/src/views/doc/agent.vue @@ -11,30 +11,35 @@ import { } from '@element-plus/icons-vue' import { userStror } from "@/utils/pinia/stores/modules/userOrders"; import router from "@/utils/router"; -import { doAiChat,getAiChatList,getAiChat,setAiChat,delAiChat,getAiagentList} from "@/api/doc/space" +import { doAiChat,getAiChatList,getAiChat,setAiChat,delAiChat,getAiagentList,getShareChat,newShareChat} from "@/api/doc/space" import {ElText,ElInput} from "element-plus"; import { VueMarkdown } from '@crazydos/vue-markdown' import rehypeRaw from 'rehype-raw' import remarkGfm from 'remark-gfm' +import { h } from 'vue' +import { useRoute } from 'vue-router' +import BottomPage from '@/views/common/bottom/index.vue' + const userStore = userStror(); const userid=ref("") +const route = useRoute() //选中的咨询模式 const checkedModel = ref([]) //支持的模式 const aimodels = [{name:'联网检索',key:"onlineSearch"}, {name:'公司知识库',key:"useDataset"}] const baseURL=import.meta.env.VITE_APP_BASE_API +const siteHost=document.location.origin; const conversation=ref("") //当前会话的uuid const myquestion=ref('') const controller = ref(null) const inputState=ref(true) const conversations=ref([]) -const centHoverItem=ref("") -const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[]}[]>([]) +const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[],share:boolean}[]>([]) const agent=ref<{name:string,uuid:string}>({name:"通用AI",uuid:import.meta.env.VITE_DEFAULT_AI_AGENT}) const agentList=ref<{name:string,uuid:string}[]>([{name:"通用AI",uuid:import.meta.env.VITE_DEFAULT_AI_AGENT}]) const respMsg=ref("") -const drawerModel=ref(false) +const drawerModel=ref(true) //消息体 interface message{ @@ -169,6 +174,21 @@ function showChat(uuid:string){ }) } +//查看分享chat记录 +function showSharedChat(uuid:string){ + drawerModel.value=false; + getShareChat(uuid).then(resp=>{ + let data=JSON.parse(resp.data.content) + data.share=true + interact_msg.value = data + // if(resp.data.agentuuid!=""){ + // agent.value={name:"会话",uuid:resp.data.agentuuid} + // } + }).catch(err=>{ + alert(err) + }) +} + //删除具体的历史记录 function onDelChat(uuid:string){ delAiChat({ @@ -208,6 +228,40 @@ function formatRefContent(content:string){ result=result.replace(/Unnamed: /g,' ') return result } +//新建分享会话记录 +function onShareChat(agID:string,chatID:string,idx:number){ + const arr=<{ask:boolean,content:string}[]>([]) + //第一条为问题,第二条为回答内容 + arr.push({ + ask:interact_msg.value[idx-1].ask, + content:interact_msg.value[idx-1].content + }) + arr.push({ + ask:interact_msg.value[idx].ask, + content:interact_msg.value[idx].content + }) + + newShareChat({ + key:agID+chatID+idx.toString(), + data:JSON.stringify(arr) + }).then(resp=>{ + let _shareURL=`${siteHost}/#/agent?shared=${resp.key}` + ElMessageBox({ + title: '分享链接', + customStyle: { padding:'20px'}, + message: () => h('div',{style:{display:'flex','flex-direction':'column','line-height':'34px'}},[ + h(ElText,{style:{'align-self':'flex-start','font-weight': 'bold'}},()=>"链接:"+_shareURL), + ]), + confirmButtonText: '复制分享链接', + showCancelButton: true + }).then(()=>{ + if(!navigator.clipboard) alert("clipboard 不可用") + navigator.clipboard.writeText(_shareURL) + }) + }).catch(err=>{ + console.log(err) + }) +} //渲染完页面再执行 onMounted(() => { @@ -223,6 +277,13 @@ onMounted(() => { }) loadKnownLibList() + + const query = route.query + //只是分享链接的请求 + if (query.shared && query.shared!=""){ + showSharedChat(query.shared as string) + } + }); @@ -250,17 +311,23 @@ onMounted(() => { + +
-