1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
import{t as e}from"./card-BDbI8Gdq.js";import{t}from"./spin-D1ik486_.js";import{t as n}from"./tag-Bn-IyYw0.js";import{Ca as r,Dn as i,Ea as a,Lt as o,Yn as s,ba as c,c as l,gn as u,rr as d,rt as f,s as p,st as m,vt as h,wn as g}from"./index-DThTpSPU.js";import{n as _,r as v}from"./agent-B0_A2P2o.js";var y=a(r(),1),b=p(),{Title:x,Text:S,Paragraph:C}=f;function w(){let{t:r}=l(),{token:a}=m.useToken(),{message:f}=d.useApp(),p=c(),[w,T]=(0,y.useState)([]),[E,D]=(0,y.useState)(!1),O=(0,y.useCallback)(async()=>{D(!0);try{T((await _()).data.data??[])}finally{D(!1)}},[]);(0,y.useEffect)(()=>{O()},[O]);let k=async(e,t)=>{try{await v(e,{enabled:t}),T(n=>n.map(n=>n.id===e?{...n,enabled:t}:n)),f.success(r(`ai.agent.update.success`))}catch{f.error(r(`ai.agent.update.failed`))}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:a.marginLG},children:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(x,{level:3,style:{marginBottom:a.marginXS},children:r(`ai.agent.page.title`)}),(0,b.jsx)(S,{type:`secondary`,children:r(`ai.agent.page.description`)})]})}),(0,b.jsx)(t,{spinning:E,children:w.length>0?(0,b.jsx)(`div`,{className:`flex flex-wrap gap-6`,children:w.map(t=>(0,b.jsx)(i,{title:t.description,children:(0,b.jsxs)(e,{hoverable:!0,variant:`borderless`,styles:{body:{width:300,padding:20,overflow:`hidden`}},children:[(0,b.jsxs)(`div`,{className:`flex justify-between items-center mb-2.5`,children:[(0,b.jsxs)(o,{align:`center`,children:[(0,b.jsx)(g,{src:t.icon,size:32}),(0,b.jsx)(`span`,{style:{fontWeight:700,fontSize:18},children:t.name})]}),(0,b.jsx)(h,{checked:t.enabled,size:`small`,onChange:e=>k(t.id,e)})]}),(0,b.jsx)(C,{type:`secondary`,ellipsis:{rows:2},style:{marginBottom:a.marginSM},children:t.description}),(0,b.jsx)(o,{size:[4,4],wrap:!0,children:t.tags?.map(e=>(0,b.jsx)(n,{color:`blue`,children:e},e))}),(0,b.jsx)(`div`,{style:{marginTop:a.marginSM},children:(0,b.jsx)(u,{type:`primary`,size:`small`,block:!0,onClick:()=>p(`/ai/chat?agent_id=${t.id}`),children:r(`ai.agent.goChat`)})})]})}))}):(0,b.jsx)(s,{description:r(`ai.agent.empty`)})})]})}export{w as default}; |