AiChat-3pVz-PVy.js 4.3 KB

1
  1. var G=(I,y,i)=>new Promise((k,_)=>{var w=s=>{try{t(i.next(s))}catch(u){_(u)}},r=s=>{try{t(i.throw(s))}catch(u){_(u)}},t=s=>s.done?k(s.value):Promise.resolve(s.value).then(w,r);t((i=i.apply(I,y)).next())});import{d as Y,ap as Z,f as l,o as $,b as Q,w as H,aq as L,ar as p,aA as P,aB as T,F as W,at as n,ah as M,as as K,u as X,n as N}from"./vue-vendor-Be68asQ6.js";import ee from"./slide-CpvuCMm7.js";import ae from"./chat-DNOp4Wum.js";import{n as te}from"./antd-vue-vendor-DcqS7Wvq.js";import{ah as le,j as D,bh as se,a as ue}from"./index-BFfnEkVs.js";import"./ailogo-DtF_kSHs.js";import"./chatMessage-w2Up_JiZ.js";import"./chatText-CUNVf7ES.js";import"./presetQuestion-CGX7VL6v.js";import"./vxe-table-vendor-DHF2TRpV.js";const oe={class:"content"},ne=Y({__name:"AiChat",setup(I,{expose:y}){var q;const i=Z(),k=(q=le().getUserInfo)==null?void 0:q.id,_=se+k;let w=null,r=null;const t=l({}),s=l(""),u=l([]),d=l(!0),v=l(!0),f=l(null),B=l({}),o=l(""),c=l(0),x=l(""),U=()=>{d.value=!d.value},b=l(""),m=l({}),h=l(""),g=l([]),A=()=>{t.value={active:"1002",usingContext:!0,history:[{id:"1002",title:"新建聊天",isEdit:!1,disabled:!0}]},o.value="新建聊天",c.value=0},J=()=>{setTimeout(()=>{},50)},V=()=>{r=H(()=>t.value.active,a=>{var e;if(a){if(a=="1002"){s.value="1002",u.value=[],o.value="新建聊天",v.value=!1,N(()=>{v.value=!0});return}let S=t.value.history.filter(C=>C.id===a);S&&S.length>0&&(o.value=(e=S[0])==null?void 0:e.title);let O={conversationId:a};s.value=a,D.get({url:"/airag/chat/messages",params:O},{isTransformResponse:!1}).then(C=>{C.success?u.value=C.result:u.value=[],v.value=!1,N(()=>{v.value=!0})})}else u.value=[],o.value=""},{immediate:!0})};function E(a=""){D.get({url:"/airag/chat/conversations",params:{appId:a}},{isTransformResponse:!1}).then(e=>{e.success&&e.result&&e.result.length>0?(t.value.history=e.result,t.value.active=e.result[0].id,o.value=e.result[0].title,c.value=0):A(),!r&&V()}).catch(()=>{A()})}$(()=>{let a=i.currentRoute.value.params;a.appId?(b.value=a.appId,R(a.appId),E(a.appId)):(E(),g.value=[{name:"请介绍一下JeecgBoot",descr:"请介绍一下JeecgBoot"},{name:"JEECG有哪些优势?",descr:"JEECG有哪些优势?"},{name:"JEECG可以做哪些事情?",descr:"JEECG可以做哪些事情?"}])}),Q(()=>{u.value=[],o.value="",h.value="",x.value="",g.value=[]});function R(a){return G(this,null,function*(){yield D.get({url:"/airag/app/queryById",params:{id:a}},{isTransformResponse:!1}).then(e=>{e.success?(m.value=e.result,e.result&&e.result.prologue&&(h.value=e.result.prologue),e.result&&e.result.quickCommand&&(g.value=JSON.parse(e.result.quickCommand)),e.result&&e.result.presetQuestion&&(x.value=e.result.presetQuestion)):m.value={}})})}function z(a,e){o.value=a,c.value=e}function F(a){t.value.history[c.value].title==="新建聊天"&&(t.value.history[c.value].title=a,t.value.history[c.value].disabled=!1)}function j(a){b.value=a,R(a),E(a)}return y({initChat:j}),Q(()=>{r&&r()}),H(()=>f.value,()=>{f.value.offsetHeight&&(B.value={height:`${f.value.offsetHeight} px`})}),(a,e)=>(p(),L("div",{ref_key:"chatContainerRef",ref:f,class:"chat-container",style:P(B.value)},[t.value?(p(),L(W,{key:0},[n("div",{class:K(["leftArea",[d.value?"expand":"shrink"]])},[n("div",oe,[s.value?(p(),T(ee,{key:0,dataSource:t.value,onSave:J,prologue:h.value,appData:m.value,onClick:z},null,8,["dataSource","prologue","appData"])):M("",!0)]),n("div",{class:"toggle-btn",onClick:U},e[0]||(e[0]=[n("span",{class:"icon"},[n("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[n("path",{d:"M5.64645 3.14645C5.45118 3.34171 5.45118 3.65829 5.64645 3.85355L9.79289 8L5.64645 12.1464C5.45118 12.3417 5.45118 12.6583 5.64645 12.8536C5.84171 13.0488 6.15829 13.0488 6.35355 12.8536L10.8536 8.35355C11.0488 8.15829 11.0488 7.84171 10.8536 7.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645Z",fill:"currentColor"})])],-1)]))],2),n("div",{class:K(["rightArea",[d.value?"expand":"shrink"]])},[s.value&&v.value?(p(),T(ae,{key:0,url:"/airag/chat/send",uuid:s.value,historyData:u.value,type:"view",onSave:J,formState:m.value,prologue:h.value,presetQuestion:x.value,onReloadMessageTitle:F,chatTitle:o.value,quickCommandData:g.value},null,8,["uuid","historyData","formState","prologue","presetQuestion","chatTitle","quickCommandData"])):M("",!0)],2)],64)):(p(),T(X(te),{key:1,spinning:!0}))],4))}}),ye=ue(ne,[["__scopeId","data-v-4bb40977"]]);export{ye as default};