Compare commits

...

5 Commits

  1. 2
      .env.production
  2. 25
      src/api/doc/space.ts
  3. 5
      src/router/index.ts
  4. 73
      src/views/doc/agent.vue
  5. 3
      src/views/doc/manage.vue
  6. 183
      src/views/doc/showtext.vue
  7. 3
      src/views/doc/space.vue

2
.env.production

@ -7,4 +7,4 @@ VITE_APP_TOKEN_KEY = 'onlineAccessSystemAppToken'
VITE_APP_SJZT_URL = 'http://120.224.6.6:29911/prod-api'
VITE_OFFICE_HOST='https://gyhlw.hxgk.group/kkapi'
VITE_ONLYOFFICE_HOST = 'https://gyhlw.hxgk.group/onlyoffice'
VITE_DEFAULT_AI_AGENT = '23a3c2c5-2de1-40df-59fa-a9206b11861d'
VITE_DEFAULT_AI_AGENT = '74938263-ffe5-43c5-90af-25e62d34a51f'

25
src/api/doc/space.ts

@ -221,3 +221,28 @@ export function getAiagentList(data?: any){
data: data
});
}
/**
*
* @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
});
}

5
src/router/index.ts

@ -38,6 +38,11 @@ export const constantRoutes: RouteRecordRaw[] = [
component: () => import("@/views/doc/onlyoffice.vue"),
meta: { hidden: true },
},
{
path: "/agent",
component: () => import("@/views/doc/showtext.vue"),
meta: { hidden: true },
},
{
path: "/",

73
src/views/doc/agent.vue

@ -5,11 +5,11 @@
-->
<script lang="ts" setup>
import {
Promotion,
Promotion,DocumentCopy,
Remove
} from '@element-plus/icons-vue'
import { doAiTraining,doAiChat,aiChatData,getAiChatList,getAiChat,setAiChat,delAiChat} from "@/api/doc/space"
import {ElText,ElInput, ButtonInstance} from "element-plus";
import { doAiChat,getAiChatList,getAiChat,setAiChat,delAiChat,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'
@ -19,6 +19,7 @@ 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<AbortController | null>(null)
@ -36,6 +37,10 @@ const props = withDefaults(defineProps<{
const respMsg=ref("")
watch(props,()=>{
currentAgent.value=props.agent
})
//
interface message{
ask:boolean,
@ -217,6 +222,49 @@ function formatRefContent(content:string){
return result
}
//
function onCopyChat(idx:number){
let el = document.querySelector('#content'+idx) as HTMLElement | null;
let content = el?.innerText;
if(!navigator.clipboard) alert("clipboard 不可用")
navigator.clipboard.writeText(content as string)
}
//
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: { '--el-messagebox-width':'800px',padding:'40px'},
message: () => h('div',{style:{display:'flex','flex-direction':'column','line-height':'34px', width:'600px'}},[
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(() => {
currentAgent.value=props.agent
@ -246,11 +294,16 @@ onMounted(() => {
</div>
<div style="position: relative;background: white;overflow-y: auto;">
<div class="reply_area" >
<template v-for="msg of interact_msg">
<template v-for="msg,index of interact_msg">
<el-text v-if="msg.ask" class="t_ask" >{{ msg.content }}</el-text>
<div v-else class="t_resp">
<el-text style="white-space: pre-line" v-html="msg.think"></el-text>
<VueMarkdown :markdown="msg.content" :rehype-plugins="[rehypeRaw]" :remark-plugins="[remarkGfm]" ></VueMarkdown>
<VueMarkdown :id="'content'+index" :markdown="msg.content" :rehype-plugins="[rehypeRaw]" :remark-plugins="[remarkGfm]" ></VueMarkdown>
<div v-if="conversation" class="actions">
<el-button :icon="Promotion" size="small" circle @click="onShareChat(agent.uuid,conversation,index)"></el-button> 分享
<el-button :icon="DocumentCopy" size="small" circle @click="onCopyChat(index)"></el-button> 复制
</div>
<div v-if="msg.docinfo?.length>0" class="doc_ref">
引用<hr>
<el-tooltip v-for="doc in msg.docinfo" placement="top" effect="dark">
@ -327,6 +380,13 @@ onMounted(() => {
font-size: 16px;
color: black;
}
.actions{
display: flex;
width: 100%;
margin: 5px 0;
background-color: #f3f3f3;
justify-content: center;
}
.dynamic-width-message-box-byme .el-message-box__message{
width: 100%;
}
@ -411,6 +471,9 @@ onMounted(() => {
ul{
margin-left: 30px;
list-style: disc;
li{
list-style: disc;
}
ul{
margin-left: 30px;
}

3
src/views/doc/manage.vue

@ -347,9 +347,6 @@ function onLoadMatterList(){
}
//----------for dir-----------
function createDir(){
if(matterList.value){
if (matterList.value[0].name=="") return;
}
matterList.value?.unshift({
name:"",
userUuid:uid,

183
src/views/doc/showtext.vue

@ -0,0 +1,183 @@
<!--
@ 作者: han2015
@ 时间: 2025-05-12 15:39:13
@ 备注: aibot组件
-->
<script lang="ts" setup>
import { getShareChat} from "@/api/doc/space"
import {ElText} from "element-plus";
import { VueMarkdown } from '@crazydos/vue-markdown'
import rehypeRaw from 'rehype-raw'
import remarkGfm from 'remark-gfm'
import { useRoute } from 'vue-router'
const route = useRoute()
const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[],share:boolean}[]>([])
//
interface message{
ask:boolean,
think:string,
content:string
}
//
interface chatRecord{
uuid:string,
agentuuid:string,
brief:string,
messages:message[]
}
//chat
function showSharedChat(uuid:string){
getShareChat(uuid).then(resp=>{
let data=JSON.parse(resp.data.content)
data.share=true
interact_msg.value = data
}).catch(err=>{
alert(err)
})
}
//
onMounted(() => {
const query = route.query
//
if (query.shared && query.shared!=""){
showSharedChat(query.shared as string)
}
});
</script>
<template>
<div class="app_container">
<div class="reply_area" >
<span class="text_title">恒信高科AI平台</span>
<template v-for="msg,index of interact_msg">
<el-text v-if="msg.ask" class="t_ask" >{{ msg.content }}</el-text>
<div v-else class="t_resp">
<el-text style="white-space: pre-line" v-html="msg.think"></el-text>
<VueMarkdown :id="'content'+index" :markdown="msg.content" :rehype-plugins="[rehypeRaw]" :remark-plugins="[remarkGfm]" ></VueMarkdown>
</div>
</template>
</div>
</div>
</template>
<style lang="scss" scoped>
.app_container {
height: calc(100vh - 65px);
width: 50%;
overflow-y:auto;
background-color: #efefef;
margin: auto;
}
.text_title{
text-align: center;
margin-bottom: 12px;
font-size: larger;
font-weight: bold;
}
.question_com{
position: fixed;
padding: 0 13px;
text-align: center;
display: block;
button{
position: absolute;
bottom: 27px;
right: 20px;
}
}
.reply_area{
display: flex;
min-height: 20%;
flex-direction: column;
margin: 15px 15px 210px 15px;
}
.t_ask{
align-self: end;
line-height: 34px;
background-color: rgb(188 211 241);
padding: 0 30px;
border-radius:10px;
}
.t_resp{
align-self: start;
line-height: 23px;
font-size: 13px;
color: black;
}
.actions{
display: flex;
width: 100%;
margin: 5px 0;
background-color: #f3f3f3;
justify-content: center;
}
.dynamic-width-message-box-byme .el-message-box__message{
width: 100%;
}
</style>
<style>
think {
color: #939393;
margin-bottom: 8px;
display: block;
}
.t_resp{
h2,h3,h4,h5{
margin: 12px 0;
}
p{
margin-left: 16px;
}
p+ul{
margin-left: 56px;
}
li p{
margin-left: 0;
}
ol{
margin-left: 14px;
ul{
margin-left: 30px;
li{
list-style: disc;
}
}
}
ol>li{
list-style-type: decimal;
}
ul{
margin-left: 30px;
list-style: disc;
li{
list-style: disc;
}
ul{
margin-left: 30px;
}
}
table{
border: 0px solid;
border-spacing: 1px;
border-collapse: collapse;
th{
background-color: #e5e5e5;
border: 1px solid;
min-width: 180px;
}
td{
border: 1px solid;
min-width: 180px;
}
}
}
</style>

3
src/views/doc/space.vue

@ -234,6 +234,7 @@ function onLoadMatterList(name?:string){
}).map(val => {
const copy = structuredClone(toRaw(val))
copy.dir = !copy.dir
copy.manager=props.ismanager
return copy
})
@ -482,7 +483,7 @@ function handleAiUpload(info:matterInfo){
})
})
}else{
alert("当前路径没有智能体")
console.log("当前路径没有智能体,不需要训练")
}
}

Loading…
Cancel
Save