You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
5.0 KiB

import{d as I,aO as L,r as M,ap as $,o as c,f as v,w as n,b as o,l as a,ae as r,c as b,F as A,k as z,e as m,t as _,aq as F,af as h,p as R,Y as T,a8 as j,a9 as O,aP as q,C as U,Z as G,G as Q,a as g,P as x,L as P,ag as Y,ab as Z,ai as H,ar as J,aQ as K,aR as W,a3 as X,a2 as ee,v as te}from"./index-4533c179.js";/* empty css *//* empty css *//* empty css */const ae=I({__name:"AssistantAdd",setup(B){const e=L(),i=M({name:"",action:"",prompt:"",isdef:0});$(async()=>{if(e.editId>0){const s=await e.getPromptById(e.editId);i.value={name:s.name,action:s.action,prompt:s.prompt,isdef:s.isdef.toString()}}else i.value={name:"",action:"",prompt:"",isdef:0}});const C=()=>{const s=[];return e.promptAction.forEach(t=>{const f={title:r("prompt."+t),value:t};s.push(f)}),s};async function V(){const s=F(i.value);if(s.name==""){h("Name cannot be empty");return}if(s.action==""){h("Action cannot be empty");return}if(!await e.savePromptData(s)){h("Save failed");return}}return(s,t)=>{const f=R,u=T,p=j,k=O,E=q,w=U,y=G;return c(),v(y,{"label-width":"100px",style:{"margin-top":"12px"}},{default:n(()=>[o(u,{label:a(r)("common.title")},{default:n(()=>[o(f,{modelValue:i.value.name,"onUpdate:modelValue":t[0]||(t[0]=d=>i.value.name=d),placeholder:a(r)("common.inputTitle"),"prefix-icon":"Notification",clearable:"",autofocus:!0},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:a(r)("common.cate")},{default:n(()=>[o(k,{modelValue:i.value.action,"onUpdate:modelValue":t[1]||(t[1]=d=>i.value.action=d)},{default:n(()=>[(c(!0),b(A,null,z(C(),(d,S)=>(c(),v(p,{key:S,label:d.title,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),o(u,{label:a(r)("common.isDef")},{default:n(()=>[o(E,{modelValue:i.value.isdef,"onUpdate:modelValue":t[2]||(t[2]=d=>i.value.isdef=d),"active-value":"1","inactive-value":"0"},null,8,["modelValue"])]),_:1},8,["label"]),o(u,{label:a(r)("common.content")},{default:n(()=>[o(f,{type:"textarea",modelValue:i.value.prompt,"onUpdate:modelValue":t[3]||(t[3]=d=>i.value.prompt=d),rows:6},null,8,["modelValue"])]),_:1},8,["label"]),o(u,null,{default:n(()=>[o(w,{type:"primary",onClick:V},{default:n(()=>[m(_(a(r)("common.confim")),1)]),_:1})]),_:1})]),_:1})}}}),oe={class:"assistant-main"},le={class:"button-group"},ne={style:{padding:"15px"}},se={class:"card-header"},ie={style:{"font-size":"14px"}},re={class:"card-header-right"},de={style:{display:"flex","align-items":"center","margin-top":"5px"}},ce=I({__name:"assistant",setup(B){const e=L();Q(async()=>{await e.getPromptList()});function i(){e.editId=0,e.showAdd=!0}async function C(s){e.editId=s.id,e.showAdd=!0}async function V(s){if(await e.deletePrompt(s.id))J(r("prompt.delSuccess"));else{h(r("prompt.contDelete"));return}}return(s,t)=>{const f=ae,u=Y,p=U,k=K,E=Z,w=H,y=W,d=X,S=ee;return c(),b("div",oe,[o(u,{modelValue:a(e).showAdd,"onUpdate:modelValue":t[0]||(t[0]=l=>a(e).showAdd=l),width:"600",title:a(r)("common.add")},{default:n(()=>[o(f)]),_:1},8,["modelValue","title"]),o(E,{modelValue:a(e).showLeft,"onUpdate:modelValue":t[2]||(t[2]=l=>a(e).showLeft=l),direction:"ltr",style:{height:"100vh"},width:"300px","show-close":!1,"with-header":!1},{default:n(()=>[o(k,{direction:"vertical",alignment:"flex-start"},{default:n(()=>[o(p,{type:"primary",style:{width:"150px"}},{default:n(()=>[m(_(a(r)("prompt.cate")),1)]),_:1}),o(p,{onClick:t[1]||(t[1]=x(l=>a(e).changeCate("all"),["stop"])),text:""},{default:n(()=>[m(_(a(r)("prompt.all")),1)]),_:1}),(c(!0),b(A,null,z(a(e).promptAction,l=>(c(),v(p,{onClick:x(D=>a(e).changeCate(l),["stop"]),text:""},{default:n(()=>[m(_(a(r)("prompt."+l)),1)]),_:2},1032,["onClick"]))),256))]),_:1})]),_:1},8,["modelValue"]),g("div",le,[o(p,{onClick:x(a(e).handlerLeft,["stop"]),icon:"Menu",circle:""},null,8,["onClick"]),o(p,{onClick:x(i,["stop"]),icon:"Plus",circle:""})]),g("div",ne,[(c(!0),b(A,null,z(a(e).promptList,(l,D)=>(c(),v(d,{class:"model-item",key:D,shadow:"hover",style:{margin:"8px 0"}},{default:n(()=>[g("div",se,[o(w,{type:"flex",justify:"space-between"},{default:n(()=>[g("span",ie,_(l.name),1),g("div",re,[o(p,{icon:"Edit",circle:"",onClick:N=>C(l)},null,8,["onClick"]),o(p,{icon:"Delete",circle:"",onClick:N=>V(l)},null,8,["onClick"])])]),_:2},1024)]),g("div",de,[o(y,{size:"small",style:{"margin-right":"5px"}},{default:n(()=>[m(_(l.action),1)]),_:2},1024),o(y,{size:"small",style:{"margin-right":"5px"}},{default:n(()=>[m(_(l.lang),1)]),_:2},1024),l.isdef>0?(c(),v(y,{key:0,size:"small"},{default:n(()=>t[6]||(t[6]=[m("default")])),_:1})):P("",!0)])]),_:2},1024))),128)),a(e).page.pages>1?(c(),v(w,{key:0,justify:"center",style:{"margin-top":"15px"}},{default:n(()=>[o(S,{background:"",layout:"prev, pager, next","current-page":a(e).page.current,"onUpdate:currentPage":t[3]||(t[3]=l=>a(e).page.current=l),"page-size":a(e).page.size,"onUpdate:pageSize":t[4]||(t[4]=l=>a(e).page.size=l),total:a(e).page.total,onCurrentChange:t[5]||(t[5]=l=>a(e).pageClick(l))},null,8,["current-page","page-size","total"])]),_:1})):P("",!0)])])}}});const fe=te(ce,[["__scopeId","data-v-bdc6ec53"]]);export{fe as default};