@zhin.js/console 1.0.39 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/client/src/main.tsx +1 -3
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/client/src/main.tsx
CHANGED
|
@@ -59,13 +59,11 @@ function RouteInitializer() {
|
|
|
59
59
|
path: '/',
|
|
60
60
|
title: 'Dashboard',
|
|
61
61
|
element: <DashboardLayout />,
|
|
62
|
-
redirect: '/dashboard',
|
|
63
62
|
meta: { order: 0 },
|
|
64
63
|
children: [
|
|
65
64
|
{
|
|
66
65
|
key: 'dashboard-home',
|
|
67
|
-
|
|
68
|
-
path: '',
|
|
66
|
+
path: '/dashboard',
|
|
69
67
|
title: '系统概览',
|
|
70
68
|
icon: <Home className="w-4 h-4" />,
|
|
71
69
|
element: <DashboardHome />,
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@ import{jsx as e,jsxs as a,Fragment as ae}from"./react-jsx-runtime.js";import*as
|
|
|
4
4
|
${t.description||""}`,rows:4,className:"font-mono text-sm"})]}):a("div",{className:"space-y-2",children:[i.map((o,m)=>e(w,{className:"group",children:a("div",{className:"p-3 space-y-2",children:[a("div",{className:"flex justify-between items-center",children:[e(y,{variant:"secondary",className:"font-mono",children:m+1}),e(I,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>n(i.filter((u,S)=>S!==m)),children:e(fe,{className:"w-3 h-3"})})]}),e("div",{className:"pl-2 border-l-2",children:d&&l(`${r}[${m}]`,d,o,u=>{c?.(r,m,u)})})]})},m)),a(I,{variant:"outline",size:"sm",className:"w-full border-dashed",onClick:()=>n([...i,d?.default||(d?.type==="object"?{}:"")]),children:[e(St,{className:"w-4 h-4 mr-1"})," 添加项"]})]})}function Mr({field:r,value:t,onChange:s}){return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Je,{className:"w-3 h-3"})," 数组输入 (每行一个值)"]}),e(U,{value:Array.isArray(t)?t.join(`
|
|
5
5
|
`):"",onChange:n=>s(n.target.value.split(`
|
|
6
6
|
`).filter(Boolean)),placeholder:`每行一个值
|
|
7
|
-
${r.description||""}`,rows:3,className:"font-mono text-sm"})]})}function Vr({fieldName:r,field:t,value:s,onArrayItemChange:n,renderNestedField:c}){const l=Array.isArray(s)?s:[],i=t.list||[];return e("div",{className:"space-y-2",children:i.map((d,o)=>a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a(y,{variant:"secondary",className:"font-mono",children:["#",o+1]}),d.description&&e("p",{className:"text-xs text-muted-foreground",children:d.description}),e("div",{className:"mt-1",children:c(`${r}[${o}]`,d,l[o],m=>{n?.(r,o,m)})})]},o))})}function Br({fieldName:r,field:t,renderField:s}){const n=t.dict||t.properties||{};return a("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[a("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[e(z,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-xs font-semibold text-muted-foreground",children:"对象"})]}),e("div",{className:"p-3 space-y-2",children:Object.entries(n).map(([c,l],i)=>a("div",{children:[a("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-semibold",children:l.key||c}),l.required&&e("span",{className:"text-destructive font-bold",children:"*"})]}),l.description&&e("p",{className:"text-xs text-muted-foreground",children:l.description}),e("div",{className:"mt-1",children:s(c,l,r)})]}),i<Object.entries(n).length-1&&e(q,{className:"my-2"})]},c))})]})}function Ur({field:r,value:t,onChange:s}){return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Ue,{className:"w-3 h-3"})," 键值对编辑"]}),e(U,{value:typeof t=="object"?JSON.stringify(t,null,2):t||"{}",onChange:n=>{try{s(JSON.parse(n.target.value))}catch{}},placeholder:r.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm"}),a("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e(ne,{className:"w-3 h-3"})," 键值对格式: ","{",'"key": "value"',"}"]})]})}function Jr({field:r,value:t,onChange:s}){const n=r.list||[];if(n.length===0)return e(_,{value:t||"",onChange:l=>s(l.target.value),placeholder:r.description||"请输入值"});const c=n.map(l=>l.default||l.type);return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(kt,{className:"w-3 h-3"})," 联合类型"]}),a(je,{value:t?.toString()||"",onValueChange:s,children:[e(le,{children:e(Ie,{placeholder:"请选择"})}),e(oe,{children:c.map((l,i)=>e(J,{value:String(l),children:String(l)},i))})]})]})}function Wr({fieldName:r,field:t,value:s,onChange:n,renderNestedField:c}){const l=t.list||[];return a("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[a("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[e(we,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-xs font-semibold text-muted-foreground",children:"交叉类型"})]}),e("div",{className:"p-3 space-y-2",children:l.map((i,d)=>a("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[i.description&&e("p",{className:"text-xs text-muted-foreground",children:i.description}),e("div",{className:"mt-1",children:c(`${r}[${d}]`,i,s,n)})]},d))})]})}function qr(r){const{field:t}=r;switch(t.type){case"string":return e(Or,{...r});case"number":case"integer":return e(Pr,{...r});case"boolean":return e(Er,{...r});case"percent":return e(Lr,{...r});case"date":return e(_r,{...r});case"regexp":return e($r,{...r});case"const":return e(Fr,{...r});case"any":return e(zr,{...r});case"list":return e(Dr,{...r});case"array":return e(Mr,{...r});case"tuple":return e(Vr,{...r});case"object":return e(Br,{...r});case"dict":return e(Ur,{...r});case"union":return e(Jr,{...r});case"intersect":return e(Wr,{...r});default:return e(U,{value:typeof r.value=="object"?JSON.stringify(r.value,null,2):r.value||"",onChange:s=>{try{r.onChange(JSON.parse(s.target.value))}catch{r.onChange(s.target.value)}},placeholder:t.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function Ye({field:r,value:t,onChange:s}){switch(r.type){case"string":return e(_,{value:t||"",onChange:n=>s(n.target.value),placeholder:r.description||"请输入",className:"h-8 text-sm"});case"number":case"integer":return e(_,{type:"number",value:t?.toString()||"",onChange:n=>s(parseFloat(n.target.value)||0),placeholder:r.description||"请输入数字",min:r.min,max:r.max,className:"h-8 text-sm"});case"boolean":return a("div",{className:"flex items-center gap-2",children:[e(Re,{checked:t===!0,onCheckedChange:s}),e("span",{className:`text-sm ${t?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:t?"已启用":"已禁用"})]});case"object":{const n=r.dict||r.properties||{};return e(w,{className:"p-2 space-y-2",children:Object.entries(n).map(([c,l])=>a("div",{className:"space-y-1",children:[e("span",{className:"text-xs font-semibold",children:c}),e(Ye,{fieldName:c,field:l,value:t?.[c],onChange:i=>s({...t,[c]:i})})]},c))})}default:return e(U,{value:typeof t=="object"?JSON.stringify(t,null,2):t||"",onChange:n=>{try{s(JSON.parse(n.target.value))}catch{s(n.target.value)}},rows:3,className:"font-mono text-xs"})}}const Hr=Y.Root,Qe=g.forwardRef(({className:r,...t},s)=>e(Y.Item,{ref:s,className:f("border-b",r),...t}));Qe.displayName="AccordionItem";const et=g.forwardRef(({className:r,children:t,...s},n)=>e(Y.Header,{className:"flex",children:a(Y.Trigger,{ref:n,className:f("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",r),...s,children:[t,e(Se,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));et.displayName="AccordionTrigger";const tt=g.forwardRef(({className:r,children:t,...s},n)=>e(Y.Content,{ref:n,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e("div",{className:f("pb-4 pt-0",r),children:t})}));tt.displayName="AccordionContent";function Gr({pluginName:r,onSuccess:t}){const[s,n]=N({}),[c,l]=N(null),[i,d]=N(void 0),{config:o,schema:m,loading:u,error:S,connected:v,setConfig:C}=Bt(r);F(()=>{o&&n(o)},[o]);const R=async()=>{if(v)try{await C(s),l("配置已保存成功"),setTimeout(()=>{d(void 0),t?.(),l(null)},1500)}catch(p){console.error("保存配置失败:",p)}},j=(p,x)=>{n(b=>({...b,[p]:x}))},P=(p,x,b)=>{n(A=>({...A,[p]:{...A[p]||{},[x]:b}}))},$=(p,x,b)=>{n(A=>{const ie=Array.isArray(A[p])?[...A[p]]:[];return ie[x]=b,{...A,[p]:ie}})},D=(p,x,b)=>{const A=b?s[b]?.[p]??x.default:s[p]??x.default;return e(qr,{fieldName:p,field:x,value:A,onChange:b?G=>P(b,p,G):G=>j(p,G),parentPath:b,onNestedChange:P,onArrayItemChange:$,renderField:D,renderNestedField:(G,st,nt,ct)=>e(Ye,{fieldName:G,field:st,value:nt,onChange:ct})})},h=m?.properties||m?.dict||{};return!m||!h||Object.keys(h).length===0?null:e(w,{className:"mt-4",children:e(Hr,{type:"single",collapsible:!0,value:i,onValueChange:d,children:a(Qe,{value:"config",className:"border-none",children:[e(et,{className:"px-4 hover:no-underline",children:a("div",{className:"flex items-center gap-2",children:[e(ye,{className:"w-4 h-4"}),e("span",{className:"font-semibold",children:"插件配置"}),a(y,{variant:"secondary",children:[Object.keys(h).length," 项"]})]})}),a(tt,{className:"px-4 pb-4",children:[c&&a(V,{variant:"success",className:"mb-3",children:[e(Ct,{className:"h-4 w-4"}),e(B,{children:c})]}),S&&a(V,{variant:"destructive",className:"mb-3",children:[e(H,{className:"h-4 w-4"}),e(B,{children:S})]}),e("div",{className:"space-y-3",children:Object.entries(h).map(([p,x])=>{const b=x;return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-semibold",children:b.key||p}),b.required&&e("span",{className:"text-destructive font-bold",children:"*"})]}),b.description&&e("p",{className:"text-xs text-muted-foreground",children:b.description}),e("div",{className:"mt-1",children:D(b.key||p,b)})]},p)})}),a("div",{className:"flex gap-2 justify-end mt-4 pt-3 border-t",children:[a(I,{variant:"outline",size:"sm",onClick:()=>d(void 0),disabled:u,children:[e(Rt,{className:"w-4 h-4 mr-1"})," 取消"]}),e(I,{size:"sm",onClick:R,disabled:u,children:u?a(ae,{children:[e(jt,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):a(ae,{children:[e(It,{className:"w-4 h-4 mr-1"}),"保存配置"]})})]})]})]})})})}const Kr={Terminal:Ve,Box:Me,Layers:we,Clock:xe,Brain:De,Wrench:ze,Database:se,Shield:Fe,Settings:ye,Plug:ve,Server:Ne};function _e(r){return Kr[r]||z}function Zr(){const{name:r}=Kt(),t=Ce(),[s,n]=N(null),[c,l]=N(!0),[i,d]=N(null);F(()=>{r&&o(r)},[r]);const o=async m=>{try{const u=await M(`/api/plugins/${encodeURIComponent(m)}`);if(!u.ok)throw new Error("API 请求失败");const S=await u.json();if(S.success)n(S.data),d(null);else throw new Error("数据格式错误")}catch(u){d(u.message)}finally{l(!1)}};return c?a("div",{className:"space-y-4",children:[e(T,{className:"h-8 w-24"}),a("div",{className:"flex items-center gap-3",children:[e(T,{className:"h-12 w-12 rounded-xl"}),a("div",{children:[e(T,{className:"h-6 w-48"}),e(T,{className:"h-4 w-64 mt-1"})]})]}),e("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[...Array(6)].map((m,u)=>e(T,{className:"h-20"},u))})]}):i||!s?a("div",{children:[a(I,{variant:"ghost",onClick:()=>t("/plugins"),className:"mb-4",children:[e(Te,{className:"w-4 h-4 mr-1"})," 返回"]}),a(V,{variant:"destructive",children:[e(H,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",i||"插件不存在"]})]})]}):a("div",{className:"space-y-4",children:[a(I,{variant:"ghost",size:"sm",onClick:()=>t("/plugins"),children:[e(Te,{className:"w-4 h-4 mr-1"})," 返回"]}),a("div",{className:"flex items-center gap-3",children:[e("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-secondary",children:e(z,{className:"w-6 h-6"})}),a("div",{children:[a("div",{className:"flex items-center gap-2",children:[e("h1",{className:"text-xl font-bold",children:s.name}),e(y,{variant:s.status==="active"?"success":"secondary",children:s.status==="active"?"运行中":"已停止"})]}),e("p",{className:"text-sm text-muted-foreground",children:s.description||"暂无描述"})]})]}),e(Gr,{pluginName:s.name,onSuccess:()=>{}}),e(q,{}),s.features.length>0&&a("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[s.features.map(m=>{const u=_e(m.icon);return e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-3",children:[e(u,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-2xl font-bold",children:m.count}),e("span",{className:"text-xs text-muted-foreground",children:m.desc})]})},m.name)}),s.contexts.length>0&&e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-3",children:[e(se,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-2xl font-bold",children:s.contexts.length}),e("span",{className:"text-xs text-muted-foreground",children:"上下文"})]})})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.features.map(m=>{if(m.items.length===0)return null;const u=_e(m.icon);return a(w,{children:[e(E,{className:"pb-2",children:a("div",{className:"flex items-center gap-2",children:[e(u,{className:"w-4 h-4 text-muted-foreground"}),e(L,{className:"text-base",children:m.desc}),e(y,{variant:"secondary",children:m.count})]})}),e(k,{children:e("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:m.items.map((S,v)=>e(Xr,{featureName:m.name,item:S},v))})})]},m.name)}),s.contexts.length>0&&a(w,{children:[e(E,{className:"pb-2",children:a("div",{className:"flex items-center gap-2",children:[e(se,{className:"w-4 h-4 text-muted-foreground"}),e(L,{className:"text-base",children:"上下文"}),e(y,{variant:"secondary",children:s.contexts.length})]})}),e(k,{children:e("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:s.contexts.map((m,u)=>e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:m.name})},u))})})]})]})]})}function Xr({featureName:r,item:t}){switch(r){case"command":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc?.map((s,n)=>e("p",{className:"text-xs text-muted-foreground",children:s},n)),t.usage&&t.usage.length>0&&a("div",{children:[e("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:"用法:"}),t.usage.map((s,n)=>e("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:s},n))]}),t.examples&&t.examples.length>0&&a("div",{children:[e("span",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400",children:"示例:"}),t.examples.map((s,n)=>e("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:s},n))]})]});case"cron":return a("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[e("code",{className:"text-sm",children:t.expression}),e(y,{variant:t.running?"success":"secondary",children:t.running?"运行中":"已停止"})]});case"tool":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc&&e("p",{className:"text-xs text-muted-foreground",children:t.desc}),t.platforms&&t.platforms.length>0&&e("div",{className:"flex gap-1 flex-wrap",children:t.platforms.map((s,n)=>e(y,{variant:"outline",className:"text-[10px]",children:s},n))})]});case"skill":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc&&e("p",{className:"text-xs text-muted-foreground",children:t.desc}),t.toolCount!=null&&a("span",{className:"text-xs text-muted-foreground",children:["工具: ",t.toolCount]})]});case"config":return a("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[e("code",{className:"text-sm",children:t.name}),t.defaultValue!==void 0&&a("span",{className:"text-xs text-muted-foreground",children:["默认: ",JSON.stringify(t.defaultValue)]})]});case"permission":return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name})});case"database":return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name})});case"adapter":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[a("div",{className:"flex items-center gap-2",children:[e(ve,{className:"w-3.5 h-3.5 text-muted-foreground"}),e("code",{className:"text-sm font-semibold",children:t.name})]}),a("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[a("span",{children:["Bot: ",t.bots??0]}),a("span",{children:["在线: ",t.online??0]}),t.tools>0&&a("span",{children:["工具: ",t.tools]})]})]});case"service":return a("div",{className:"rounded-md bg-muted/50 p-2 flex items-center gap-2",children:[e(Ne,{className:"w-3.5 h-3.5 text-muted-foreground"}),e("code",{className:"text-sm",children:t.name}),t.desc&&t.desc!==t.name&&a("span",{className:"text-xs text-muted-foreground",children:["- ",t.desc]})]});default:return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name||JSON.stringify(t)})})}}function Yr(){const[r,t]=N([]),[s,n]=N(!0),[c,l]=N(null);F(()=>{i();const d=setInterval(i,5e3);return()=>clearInterval(d)},[]);const i=async()=>{try{const d=await M("/api/bots");if(!d.ok)throw new Error("API 请求失败");const o=await d.json();if(o.success)t(o.data),l(null);else throw new Error("数据格式错误")}catch(d){l(d.message)}finally{n(!1)}};return s?a("div",{className:"space-y-6",children:[e(T,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((d,o)=>e(T,{className:"h-48"},o))})]}):c?e("div",{className:"flex items-center justify-center h-full",children:a(V,{variant:"destructive",className:"max-w-md",children:[e(H,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",c]})]})}):a("div",{className:"space-y-6",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"机器人管理"}),a("div",{className:"flex items-center gap-2 mt-1",children:[a("span",{className:"text-sm text-muted-foreground",children:["共 ",r.length," 个机器人,"]}),e(y,{variant:"success",children:r.filter(d=>d.connected).length}),e("span",{className:"text-sm text-muted-foreground",children:"个在线"})]})]}),e(q,{}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map((d,o)=>e(w,{children:a(k,{className:"p-5 space-y-4",children:[a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2",children:[e("div",{className:`p-2 rounded-md ${d.connected?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"}`,children:e(X,{className:`w-5 h-5 ${d.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`})}),e("span",{className:"text-lg font-bold",children:d.name})]}),e("div",{className:"relative",children:e(y,{variant:d.connected?"success":"secondary",children:d.connected?a(ae,{children:[e(Tt,{className:"w-3 h-3 mr-1"}),"在线"]}):a(ae,{children:[e(At,{className:"w-3 h-3 mr-1"}),"离线"]})})})]}),a("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-sm text-muted-foreground",children:"适配器:"}),e(y,{variant:"outline",children:d.adapter})]}),e(q,{}),a("div",{className:"space-y-2",children:[a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(he,{className:`w-4 h-4 ${d.status==="online"?"text-emerald-500":"text-muted-foreground"}`}),e("span",{className:"text-muted-foreground",children:"运行状态"})]}),e(y,{variant:d.status==="online"?"success":"secondary",children:d.status==="online"?"运行中":"已停止"})]}),a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(z,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-muted-foreground",children:"适配器类型"})]}),e("span",{className:"text-sm font-medium",children:d.adapter})]}),a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(Ot,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-muted-foreground",children:"连接状态"})]}),e("span",{className:`text-sm font-medium ${d.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:d.connected?"已连接":"未连接"})]})]})]})},`${d.adapter}-${d.name}-${o}`))}),r.length===0&&e(w,{children:a(k,{className:"flex flex-col items-center gap-4 py-12",children:[e(X,{className:"w-16 h-16 text-muted-foreground/30"}),a("div",{className:"text-center",children:[e("h3",{className:"text-lg font-semibold",children:"暂无机器人"}),e("p",{className:"text-sm text-muted-foreground",children:"请先配置并启动机器人"})]})]})})]})}const rt=g.forwardRef(({className:r,...t},s)=>e(Oe.Root,{ref:s,className:f("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",r),...t,children:e(Oe.Indicator,{className:f("flex items-center justify-center text-current"),children:e(Be,{className:"h-4 w-4"})})}));rt.displayName="Checkbox";function Qr(){const[r,t]=N([]),[s,n]=N(null),[c,l]=N(!0),[i,d]=N(null),[o,m]=N("all"),[u,S]=N(!0),v=it(null),[C,R]=N(0);F(()=>{j(),P();const h=setInterval(()=>{j(),P()},3e3);return()=>clearInterval(h)},[o]),F(()=>{u&&r.length>C&&v.current?.scrollIntoView({behavior:"smooth"}),R(r.length)},[r,u]);const j=async()=>{try{const h=o==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${o}`,p=await M(h);if(!p.ok)throw new Error("API 请求失败");const x=await p.json();x.success&&Array.isArray(x.data)&&(t(x.data.reverse()),d(null))}catch(h){d(h.message)}finally{l(!1)}},P=async()=>{try{const h=await M("/api/logs/stats");if(!h.ok)return;const p=await h.json();p.success&&n(p.data)}catch(h){console.error("Failed to fetch stats:",h)}},$=async(h,p)=>{const x=h?`确定清理 ${h} 天前的日志吗?`:`确定只保留最近 ${p} 条日志吗?`;if(confirm(x))try{const b=await M("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:h,maxRecords:p})});if(!b.ok)throw new Error("清理失败");const A=await b.json();A.success&&(alert(`成功清理 ${A.data.deletedCount} 条日志`),j(),P())}catch(b){alert(b.message)}},D=h=>{switch(h){case"info":return{border:"border-l-blue-500",badge:"default",icon:e(ne,{className:"w-3 h-3"})};case"warn":return{border:"border-l-amber-500",badge:"warning",icon:e(_t,{className:"w-3 h-3"})};case"error":return{border:"border-l-red-500",badge:"destructive",icon:e(Lt,{className:"w-3 h-3"})};default:return{border:"border-l-gray-500",badge:"secondary",icon:e(Et,{className:"w-3 h-3"})}}};return c?a("div",{className:"space-y-4",children:[e(T,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[...Array(4)].map((h,p)=>e(T,{className:"h-20"},p))}),e(T,{className:"h-96"})]}):a("div",{className:"space-y-4",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"系统日志"}),e("p",{className:"text-sm text-muted-foreground",children:"实时查看系统运行日志"})]}),s&&a("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold",children:s.total}),e("span",{className:"text-xs text-muted-foreground",children:"总日志数"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:s.byLevel.info||0}),e("span",{className:"text-xs text-muted-foreground",children:"Info"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:s.byLevel.warn||0}),e("span",{className:"text-xs text-muted-foreground",children:"Warn"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:s.byLevel.error||0}),e("span",{className:"text-xs text-muted-foreground",children:"Error"})]})})]}),e(w,{children:a(k,{className:"flex justify-between items-center p-3 flex-wrap gap-3",children:[a("div",{className:"flex items-center gap-3 flex-wrap",children:[a(je,{value:o,onValueChange:m,children:[e(le,{className:"w-32",children:e(Ie,{placeholder:"所有级别"})}),a(oe,{children:[e(J,{value:"all",children:"所有级别"}),e(J,{value:"info",children:"Info"}),e(J,{value:"warn",children:"Warn"}),e(J,{value:"error",children:"Error"})]})]}),a("div",{className:"flex items-center gap-2",children:[e(rt,{id:"auto-scroll",checked:u,onCheckedChange:h=>S(h)}),e("label",{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"自动滚动"})]})]}),a("div",{className:"flex gap-2",children:[a(I,{variant:"outline",size:"sm",onClick:()=>$(7),children:[e(fe,{className:"w-3.5 h-3.5 mr-1"}),"清理7天前"]}),a(I,{variant:"outline",size:"sm",onClick:()=>$(void 0,5e3),children:[e(fe,{className:"w-3.5 h-3.5 mr-1"}),"保留5000条"]}),a(I,{variant:"outline",size:"sm",onClick:()=>j(),children:[e(Pt,{className:"w-3.5 h-3.5 mr-1"}),"刷新"]})]})]})}),e(w,{children:e(k,{className:"p-4",children:a("div",{className:"max-h-[600px] overflow-y-auto rounded-md bg-muted/30 p-2 space-y-1.5",children:[i?a(V,{variant:"destructive",children:[e(H,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",i]})]}):r.length===0?a("div",{className:"flex flex-col items-center gap-3 py-12",children:[e(be,{className:"w-12 h-12 text-muted-foreground/30"}),e("span",{className:"text-sm text-muted-foreground",children:"暂无日志"})]}):r.map((h,p)=>{const x=D(h.level);return a("div",{className:f("p-3 rounded-md bg-background border-l-[3px]",x.border),children:[a("div",{className:"flex items-center gap-2 mb-1",children:[a(y,{variant:x.badge,className:"gap-1 text-[10px] px-1.5 py-0",children:[x.icon," ",h.level.toUpperCase()]}),e("span",{className:"text-[11px] text-muted-foreground",children:new Date(h.timestamp).toLocaleString()}),h.source&&e(y,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:h.source})]}),e("p",{className:"text-sm font-mono whitespace-pre-wrap break-words",children:h.message})]},`${h.timestamp}-${p}`)}),e("div",{ref:v})]})})})]})}function ea({onSuccess:r}){const[t,s]=N(""),[n,c]=N(""),[l,i]=N(!1),d=$e(async()=>{const o=t.trim();if(!o){c("请输入 Token");return}i(!0),c("");try{const m=await fetch("/api/system/status",{headers:{Authorization:`Bearer ${o}`}});m.ok?(Nr(o),r()):m.status===401?c("Token 无效,请检查后重试"):c(`验证失败 (HTTP ${m.status})`)}catch{c("无法连接到服务器")}finally{i(!1)}},[t,r]);return e("div",{className:"flex items-center justify-center min-h-screen bg-background",children:a(w,{className:f("w-full max-w-md mx-4"),children:[a(E,{className:"text-center space-y-2",children:[e("div",{className:"flex items-center justify-center mx-auto w-12 h-12 rounded-xl bg-foreground text-background font-bold text-xl",children:"Z"}),e(L,{className:"text-xl",children:"Zhin.js 控制台"}),e(Z,{children:"请输入 API Token 以访问管理面板"})]}),e(k,{children:a("form",{onSubmit:o=>{o.preventDefault(),d()},className:"space-y-4",children:[a("div",{className:"space-y-2",children:[e(_,{type:"password",placeholder:"API Token",value:t,onChange:o=>{s(o.target.value),n&&c("")},autoFocus:!0}),n&&e("p",{className:"text-sm text-destructive",children:n})]}),e(I,{type:"submit",className:"w-full",disabled:l,children:l?"验证中...":"登录"}),a("p",{className:"text-xs text-center text-muted-foreground",children:["Token 位于 ",e("code",{className:"text-xs bg-muted px-1 rounded",children:".env"})," 文件的"," ",e("code",{className:"text-xs bg-muted px-1 rounded",children:"HTTP_TOKEN"})," 中"]})]})})]})})}function ee(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ee=function(s){return typeof s}:ee=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ee(r)}function ta(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function ra(r,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function aa(r,t,s){return t&&ra(r.prototype,t),r}function sa(r,t){return t&&(ee(t)==="object"||typeof t=="function")?t:te(r)}function pe(r){return pe=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},pe(r)}function te(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function na(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&ge(r,t)}function ge(r,t){return ge=Object.setPrototypeOf||function(n,c){return n.__proto__=c,n},ge(r,t)}function re(r,t,s){return t in r?Object.defineProperty(r,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[t]=s,r}var at=(function(r){na(t,r);function t(){var s,n;ta(this,t);for(var c=arguments.length,l=new Array(c),i=0;i<c;i++)l[i]=arguments[i];return n=sa(this,(s=pe(t)).call.apply(s,[this].concat(l))),re(te(n),"state",{bootstrapped:!1}),re(te(n),"_unsubscribe",void 0),re(te(n),"handlePersistorState",function(){var d=n.props.persistor,o=d.getState(),m=o.bootstrapped;m&&(n.props.onBeforeLift?Promise.resolve(n.props.onBeforeLift()).finally(function(){return n.setState({bootstrapped:!0})}):n.setState({bootstrapped:!0}),n._unsubscribe&&n._unsubscribe())}),n}return aa(t,[{key:"componentDidMount",value:function(){this._unsubscribe=this.props.persistor.subscribe(this.handlePersistorState),this.handlePersistorState()}},{key:"componentWillUnmount",value:function(){this._unsubscribe&&this._unsubscribe()}},{key:"render",value:function(){return typeof this.props.children=="function"?this.props.children(this.state.bootstrapped):this.state.bootstrapped?this.props.children:this.props.loading}}]),t})(dt);re(at,"defaultProps",{children:null,loading:null});const ca=Q.Provider;Q.Root;Q.Trigger;const la=g.forwardRef(({className:r,sideOffset:t=4,...s},n)=>e(Q.Portal,{children:e(Q.Content,{ref:n,sideOffset:t,className:f("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r),...s})}));la.displayName="TooltipContent";fr();function oa(){const[r,t]=N(vr()),s=$e(()=>t(!0),[]);return F(()=>{const n=()=>t(!1);return window.addEventListener("zhin:auth-required",n),()=>window.removeEventListener("zhin:auth-required",n)},[]),r?e(at,{loading:null,persistor:Ut,children:e(ur,{store:Jt,children:e(ia,{})})}):e(ea,{onSuccess:s})}function ia(){Wt();const r=W(i=>i.script.entries),t=W(i=>i.script.loadedScripts),s=W(i=>i.script.synced),[n,c]=N(!1);F(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:e(yr,{}),redirect:"/dashboard",meta:{order:0},children:[{key:"dashboard-home",index:!0,path:"",title:"系统概览",icon:e($t,{className:"w-4 h-4"}),element:e(Rr,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:e(z,{className:"w-4 h-4"}),element:e(Tr,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:e(Zr,{}),meta:{hideInMenu:!0}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:e(X,{className:"w-4 h-4"}),element:e(Yr,{}),meta:{order:3}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:e(be,{className:"w-4 h-4"}),element:e(Qr,{}),meta:{order:4}}]}].forEach(d=>{qt(d)}),c(!0)},[]);const l=s&&(r.length===0||r.length===t.length);return!n||!l?e("div",{className:"flex items-center justify-center h-screen bg-background",children:a("div",{className:"text-center",children:[e("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-2 border-muted-foreground border-t-foreground"}),a("p",{className:"mt-3 text-sm text-muted-foreground",children:["加载中... (",t.length,"/",r.length,")"]})]})}):e(Ht,{})}ut(document.getElementById("root")).render(e(mt,{children:e(ca,{children:e(oa,{})})}));
|
|
7
|
+
${r.description||""}`,rows:3,className:"font-mono text-sm"})]})}function Vr({fieldName:r,field:t,value:s,onArrayItemChange:n,renderNestedField:c}){const l=Array.isArray(s)?s:[],i=t.list||[];return e("div",{className:"space-y-2",children:i.map((d,o)=>a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a(y,{variant:"secondary",className:"font-mono",children:["#",o+1]}),d.description&&e("p",{className:"text-xs text-muted-foreground",children:d.description}),e("div",{className:"mt-1",children:c(`${r}[${o}]`,d,l[o],m=>{n?.(r,o,m)})})]},o))})}function Br({fieldName:r,field:t,renderField:s}){const n=t.dict||t.properties||{};return a("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[a("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[e(z,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-xs font-semibold text-muted-foreground",children:"对象"})]}),e("div",{className:"p-3 space-y-2",children:Object.entries(n).map(([c,l],i)=>a("div",{children:[a("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-semibold",children:l.key||c}),l.required&&e("span",{className:"text-destructive font-bold",children:"*"})]}),l.description&&e("p",{className:"text-xs text-muted-foreground",children:l.description}),e("div",{className:"mt-1",children:s(c,l,r)})]}),i<Object.entries(n).length-1&&e(q,{className:"my-2"})]},c))})]})}function Ur({field:r,value:t,onChange:s}){return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Ue,{className:"w-3 h-3"})," 键值对编辑"]}),e(U,{value:typeof t=="object"?JSON.stringify(t,null,2):t||"{}",onChange:n=>{try{s(JSON.parse(n.target.value))}catch{}},placeholder:r.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm"}),a("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e(ne,{className:"w-3 h-3"})," 键值对格式: ","{",'"key": "value"',"}"]})]})}function Jr({field:r,value:t,onChange:s}){const n=r.list||[];if(n.length===0)return e(_,{value:t||"",onChange:l=>s(l.target.value),placeholder:r.description||"请输入值"});const c=n.map(l=>l.default||l.type);return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(kt,{className:"w-3 h-3"})," 联合类型"]}),a(je,{value:t?.toString()||"",onValueChange:s,children:[e(le,{children:e(Ie,{placeholder:"请选择"})}),e(oe,{children:c.map((l,i)=>e(J,{value:String(l),children:String(l)},i))})]})]})}function Wr({fieldName:r,field:t,value:s,onChange:n,renderNestedField:c}){const l=t.list||[];return a("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[a("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[e(we,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-xs font-semibold text-muted-foreground",children:"交叉类型"})]}),e("div",{className:"p-3 space-y-2",children:l.map((i,d)=>a("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[i.description&&e("p",{className:"text-xs text-muted-foreground",children:i.description}),e("div",{className:"mt-1",children:c(`${r}[${d}]`,i,s,n)})]},d))})]})}function qr(r){const{field:t}=r;switch(t.type){case"string":return e(Or,{...r});case"number":case"integer":return e(Pr,{...r});case"boolean":return e(Er,{...r});case"percent":return e(Lr,{...r});case"date":return e(_r,{...r});case"regexp":return e($r,{...r});case"const":return e(Fr,{...r});case"any":return e(zr,{...r});case"list":return e(Dr,{...r});case"array":return e(Mr,{...r});case"tuple":return e(Vr,{...r});case"object":return e(Br,{...r});case"dict":return e(Ur,{...r});case"union":return e(Jr,{...r});case"intersect":return e(Wr,{...r});default:return e(U,{value:typeof r.value=="object"?JSON.stringify(r.value,null,2):r.value||"",onChange:s=>{try{r.onChange(JSON.parse(s.target.value))}catch{r.onChange(s.target.value)}},placeholder:t.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function Ye({field:r,value:t,onChange:s}){switch(r.type){case"string":return e(_,{value:t||"",onChange:n=>s(n.target.value),placeholder:r.description||"请输入",className:"h-8 text-sm"});case"number":case"integer":return e(_,{type:"number",value:t?.toString()||"",onChange:n=>s(parseFloat(n.target.value)||0),placeholder:r.description||"请输入数字",min:r.min,max:r.max,className:"h-8 text-sm"});case"boolean":return a("div",{className:"flex items-center gap-2",children:[e(Re,{checked:t===!0,onCheckedChange:s}),e("span",{className:`text-sm ${t?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:t?"已启用":"已禁用"})]});case"object":{const n=r.dict||r.properties||{};return e(w,{className:"p-2 space-y-2",children:Object.entries(n).map(([c,l])=>a("div",{className:"space-y-1",children:[e("span",{className:"text-xs font-semibold",children:c}),e(Ye,{fieldName:c,field:l,value:t?.[c],onChange:i=>s({...t,[c]:i})})]},c))})}default:return e(U,{value:typeof t=="object"?JSON.stringify(t,null,2):t||"",onChange:n=>{try{s(JSON.parse(n.target.value))}catch{s(n.target.value)}},rows:3,className:"font-mono text-xs"})}}const Hr=Y.Root,Qe=g.forwardRef(({className:r,...t},s)=>e(Y.Item,{ref:s,className:f("border-b",r),...t}));Qe.displayName="AccordionItem";const et=g.forwardRef(({className:r,children:t,...s},n)=>e(Y.Header,{className:"flex",children:a(Y.Trigger,{ref:n,className:f("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",r),...s,children:[t,e(Se,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));et.displayName="AccordionTrigger";const tt=g.forwardRef(({className:r,children:t,...s},n)=>e(Y.Content,{ref:n,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e("div",{className:f("pb-4 pt-0",r),children:t})}));tt.displayName="AccordionContent";function Gr({pluginName:r,onSuccess:t}){const[s,n]=N({}),[c,l]=N(null),[i,d]=N(void 0),{config:o,schema:m,loading:u,error:S,connected:v,setConfig:C}=Bt(r);F(()=>{o&&n(o)},[o]);const R=async()=>{if(v)try{await C(s),l("配置已保存成功"),setTimeout(()=>{d(void 0),t?.(),l(null)},1500)}catch(p){console.error("保存配置失败:",p)}},j=(p,x)=>{n(b=>({...b,[p]:x}))},P=(p,x,b)=>{n(A=>({...A,[p]:{...A[p]||{},[x]:b}}))},$=(p,x,b)=>{n(A=>{const ie=Array.isArray(A[p])?[...A[p]]:[];return ie[x]=b,{...A,[p]:ie}})},D=(p,x,b)=>{const A=b?s[b]?.[p]??x.default:s[p]??x.default;return e(qr,{fieldName:p,field:x,value:A,onChange:b?G=>P(b,p,G):G=>j(p,G),parentPath:b,onNestedChange:P,onArrayItemChange:$,renderField:D,renderNestedField:(G,st,nt,ct)=>e(Ye,{fieldName:G,field:st,value:nt,onChange:ct})})},h=m?.properties||m?.dict||{};return!m||!h||Object.keys(h).length===0?null:e(w,{className:"mt-4",children:e(Hr,{type:"single",collapsible:!0,value:i,onValueChange:d,children:a(Qe,{value:"config",className:"border-none",children:[e(et,{className:"px-4 hover:no-underline",children:a("div",{className:"flex items-center gap-2",children:[e(ye,{className:"w-4 h-4"}),e("span",{className:"font-semibold",children:"插件配置"}),a(y,{variant:"secondary",children:[Object.keys(h).length," 项"]})]})}),a(tt,{className:"px-4 pb-4",children:[c&&a(V,{variant:"success",className:"mb-3",children:[e(Ct,{className:"h-4 w-4"}),e(B,{children:c})]}),S&&a(V,{variant:"destructive",className:"mb-3",children:[e(H,{className:"h-4 w-4"}),e(B,{children:S})]}),e("div",{className:"space-y-3",children:Object.entries(h).map(([p,x])=>{const b=x;return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-semibold",children:b.key||p}),b.required&&e("span",{className:"text-destructive font-bold",children:"*"})]}),b.description&&e("p",{className:"text-xs text-muted-foreground",children:b.description}),e("div",{className:"mt-1",children:D(b.key||p,b)})]},p)})}),a("div",{className:"flex gap-2 justify-end mt-4 pt-3 border-t",children:[a(I,{variant:"outline",size:"sm",onClick:()=>d(void 0),disabled:u,children:[e(Rt,{className:"w-4 h-4 mr-1"})," 取消"]}),e(I,{size:"sm",onClick:R,disabled:u,children:u?a(ae,{children:[e(jt,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):a(ae,{children:[e(It,{className:"w-4 h-4 mr-1"}),"保存配置"]})})]})]})]})})})}const Kr={Terminal:Ve,Box:Me,Layers:we,Clock:xe,Brain:De,Wrench:ze,Database:se,Shield:Fe,Settings:ye,Plug:ve,Server:Ne};function _e(r){return Kr[r]||z}function Zr(){const{name:r}=Kt(),t=Ce(),[s,n]=N(null),[c,l]=N(!0),[i,d]=N(null);F(()=>{r&&o(r)},[r]);const o=async m=>{try{const u=await M(`/api/plugins/${encodeURIComponent(m)}`);if(!u.ok)throw new Error("API 请求失败");const S=await u.json();if(S.success)n(S.data),d(null);else throw new Error("数据格式错误")}catch(u){d(u.message)}finally{l(!1)}};return c?a("div",{className:"space-y-4",children:[e(T,{className:"h-8 w-24"}),a("div",{className:"flex items-center gap-3",children:[e(T,{className:"h-12 w-12 rounded-xl"}),a("div",{children:[e(T,{className:"h-6 w-48"}),e(T,{className:"h-4 w-64 mt-1"})]})]}),e("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[...Array(6)].map((m,u)=>e(T,{className:"h-20"},u))})]}):i||!s?a("div",{children:[a(I,{variant:"ghost",onClick:()=>t("/plugins"),className:"mb-4",children:[e(Te,{className:"w-4 h-4 mr-1"})," 返回"]}),a(V,{variant:"destructive",children:[e(H,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",i||"插件不存在"]})]})]}):a("div",{className:"space-y-4",children:[a(I,{variant:"ghost",size:"sm",onClick:()=>t("/plugins"),children:[e(Te,{className:"w-4 h-4 mr-1"})," 返回"]}),a("div",{className:"flex items-center gap-3",children:[e("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-secondary",children:e(z,{className:"w-6 h-6"})}),a("div",{children:[a("div",{className:"flex items-center gap-2",children:[e("h1",{className:"text-xl font-bold",children:s.name}),e(y,{variant:s.status==="active"?"success":"secondary",children:s.status==="active"?"运行中":"已停止"})]}),e("p",{className:"text-sm text-muted-foreground",children:s.description||"暂无描述"})]})]}),e(Gr,{pluginName:s.name,onSuccess:()=>{}}),e(q,{}),s.features.length>0&&a("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[s.features.map(m=>{const u=_e(m.icon);return e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-3",children:[e(u,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-2xl font-bold",children:m.count}),e("span",{className:"text-xs text-muted-foreground",children:m.desc})]})},m.name)}),s.contexts.length>0&&e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-3",children:[e(se,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-2xl font-bold",children:s.contexts.length}),e("span",{className:"text-xs text-muted-foreground",children:"上下文"})]})})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.features.map(m=>{if(m.items.length===0)return null;const u=_e(m.icon);return a(w,{children:[e(E,{className:"pb-2",children:a("div",{className:"flex items-center gap-2",children:[e(u,{className:"w-4 h-4 text-muted-foreground"}),e(L,{className:"text-base",children:m.desc}),e(y,{variant:"secondary",children:m.count})]})}),e(k,{children:e("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:m.items.map((S,v)=>e(Xr,{featureName:m.name,item:S},v))})})]},m.name)}),s.contexts.length>0&&a(w,{children:[e(E,{className:"pb-2",children:a("div",{className:"flex items-center gap-2",children:[e(se,{className:"w-4 h-4 text-muted-foreground"}),e(L,{className:"text-base",children:"上下文"}),e(y,{variant:"secondary",children:s.contexts.length})]})}),e(k,{children:e("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:s.contexts.map((m,u)=>e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:m.name})},u))})})]})]})]})}function Xr({featureName:r,item:t}){switch(r){case"command":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc?.map((s,n)=>e("p",{className:"text-xs text-muted-foreground",children:s},n)),t.usage&&t.usage.length>0&&a("div",{children:[e("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:"用法:"}),t.usage.map((s,n)=>e("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:s},n))]}),t.examples&&t.examples.length>0&&a("div",{children:[e("span",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400",children:"示例:"}),t.examples.map((s,n)=>e("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:s},n))]})]});case"cron":return a("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[e("code",{className:"text-sm",children:t.expression}),e(y,{variant:t.running?"success":"secondary",children:t.running?"运行中":"已停止"})]});case"tool":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc&&e("p",{className:"text-xs text-muted-foreground",children:t.desc}),t.platforms&&t.platforms.length>0&&e("div",{className:"flex gap-1 flex-wrap",children:t.platforms.map((s,n)=>e(y,{variant:"outline",className:"text-[10px]",children:s},n))})]});case"skill":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc&&e("p",{className:"text-xs text-muted-foreground",children:t.desc}),t.toolCount!=null&&a("span",{className:"text-xs text-muted-foreground",children:["工具: ",t.toolCount]})]});case"config":return a("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[e("code",{className:"text-sm",children:t.name}),t.defaultValue!==void 0&&a("span",{className:"text-xs text-muted-foreground",children:["默认: ",JSON.stringify(t.defaultValue)]})]});case"permission":return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name})});case"database":return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name})});case"adapter":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[a("div",{className:"flex items-center gap-2",children:[e(ve,{className:"w-3.5 h-3.5 text-muted-foreground"}),e("code",{className:"text-sm font-semibold",children:t.name})]}),a("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[a("span",{children:["Bot: ",t.bots??0]}),a("span",{children:["在线: ",t.online??0]}),t.tools>0&&a("span",{children:["工具: ",t.tools]})]})]});case"service":return a("div",{className:"rounded-md bg-muted/50 p-2 flex items-center gap-2",children:[e(Ne,{className:"w-3.5 h-3.5 text-muted-foreground"}),e("code",{className:"text-sm",children:t.name}),t.desc&&t.desc!==t.name&&a("span",{className:"text-xs text-muted-foreground",children:["- ",t.desc]})]});default:return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name||JSON.stringify(t)})})}}function Yr(){const[r,t]=N([]),[s,n]=N(!0),[c,l]=N(null);F(()=>{i();const d=setInterval(i,5e3);return()=>clearInterval(d)},[]);const i=async()=>{try{const d=await M("/api/bots");if(!d.ok)throw new Error("API 请求失败");const o=await d.json();if(o.success)t(o.data),l(null);else throw new Error("数据格式错误")}catch(d){l(d.message)}finally{n(!1)}};return s?a("div",{className:"space-y-6",children:[e(T,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((d,o)=>e(T,{className:"h-48"},o))})]}):c?e("div",{className:"flex items-center justify-center h-full",children:a(V,{variant:"destructive",className:"max-w-md",children:[e(H,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",c]})]})}):a("div",{className:"space-y-6",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"机器人管理"}),a("div",{className:"flex items-center gap-2 mt-1",children:[a("span",{className:"text-sm text-muted-foreground",children:["共 ",r.length," 个机器人,"]}),e(y,{variant:"success",children:r.filter(d=>d.connected).length}),e("span",{className:"text-sm text-muted-foreground",children:"个在线"})]})]}),e(q,{}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map((d,o)=>e(w,{children:a(k,{className:"p-5 space-y-4",children:[a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2",children:[e("div",{className:`p-2 rounded-md ${d.connected?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"}`,children:e(X,{className:`w-5 h-5 ${d.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`})}),e("span",{className:"text-lg font-bold",children:d.name})]}),e("div",{className:"relative",children:e(y,{variant:d.connected?"success":"secondary",children:d.connected?a(ae,{children:[e(Tt,{className:"w-3 h-3 mr-1"}),"在线"]}):a(ae,{children:[e(At,{className:"w-3 h-3 mr-1"}),"离线"]})})})]}),a("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-sm text-muted-foreground",children:"适配器:"}),e(y,{variant:"outline",children:d.adapter})]}),e(q,{}),a("div",{className:"space-y-2",children:[a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(he,{className:`w-4 h-4 ${d.status==="online"?"text-emerald-500":"text-muted-foreground"}`}),e("span",{className:"text-muted-foreground",children:"运行状态"})]}),e(y,{variant:d.status==="online"?"success":"secondary",children:d.status==="online"?"运行中":"已停止"})]}),a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(z,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-muted-foreground",children:"适配器类型"})]}),e("span",{className:"text-sm font-medium",children:d.adapter})]}),a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(Ot,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-muted-foreground",children:"连接状态"})]}),e("span",{className:`text-sm font-medium ${d.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:d.connected?"已连接":"未连接"})]})]})]})},`${d.adapter}-${d.name}-${o}`))}),r.length===0&&e(w,{children:a(k,{className:"flex flex-col items-center gap-4 py-12",children:[e(X,{className:"w-16 h-16 text-muted-foreground/30"}),a("div",{className:"text-center",children:[e("h3",{className:"text-lg font-semibold",children:"暂无机器人"}),e("p",{className:"text-sm text-muted-foreground",children:"请先配置并启动机器人"})]})]})})]})}const rt=g.forwardRef(({className:r,...t},s)=>e(Oe.Root,{ref:s,className:f("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",r),...t,children:e(Oe.Indicator,{className:f("flex items-center justify-center text-current"),children:e(Be,{className:"h-4 w-4"})})}));rt.displayName="Checkbox";function Qr(){const[r,t]=N([]),[s,n]=N(null),[c,l]=N(!0),[i,d]=N(null),[o,m]=N("all"),[u,S]=N(!0),v=it(null),[C,R]=N(0);F(()=>{j(),P();const h=setInterval(()=>{j(),P()},3e3);return()=>clearInterval(h)},[o]),F(()=>{u&&r.length>C&&v.current?.scrollIntoView({behavior:"smooth"}),R(r.length)},[r,u]);const j=async()=>{try{const h=o==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${o}`,p=await M(h);if(!p.ok)throw new Error("API 请求失败");const x=await p.json();x.success&&Array.isArray(x.data)&&(t(x.data.reverse()),d(null))}catch(h){d(h.message)}finally{l(!1)}},P=async()=>{try{const h=await M("/api/logs/stats");if(!h.ok)return;const p=await h.json();p.success&&n(p.data)}catch(h){console.error("Failed to fetch stats:",h)}},$=async(h,p)=>{const x=h?`确定清理 ${h} 天前的日志吗?`:`确定只保留最近 ${p} 条日志吗?`;if(confirm(x))try{const b=await M("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:h,maxRecords:p})});if(!b.ok)throw new Error("清理失败");const A=await b.json();A.success&&(alert(`成功清理 ${A.data.deletedCount} 条日志`),j(),P())}catch(b){alert(b.message)}},D=h=>{switch(h){case"info":return{border:"border-l-blue-500",badge:"default",icon:e(ne,{className:"w-3 h-3"})};case"warn":return{border:"border-l-amber-500",badge:"warning",icon:e(_t,{className:"w-3 h-3"})};case"error":return{border:"border-l-red-500",badge:"destructive",icon:e(Lt,{className:"w-3 h-3"})};default:return{border:"border-l-gray-500",badge:"secondary",icon:e(Et,{className:"w-3 h-3"})}}};return c?a("div",{className:"space-y-4",children:[e(T,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[...Array(4)].map((h,p)=>e(T,{className:"h-20"},p))}),e(T,{className:"h-96"})]}):a("div",{className:"space-y-4",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"系统日志"}),e("p",{className:"text-sm text-muted-foreground",children:"实时查看系统运行日志"})]}),s&&a("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold",children:s.total}),e("span",{className:"text-xs text-muted-foreground",children:"总日志数"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:s.byLevel.info||0}),e("span",{className:"text-xs text-muted-foreground",children:"Info"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:s.byLevel.warn||0}),e("span",{className:"text-xs text-muted-foreground",children:"Warn"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:s.byLevel.error||0}),e("span",{className:"text-xs text-muted-foreground",children:"Error"})]})})]}),e(w,{children:a(k,{className:"flex justify-between items-center p-3 flex-wrap gap-3",children:[a("div",{className:"flex items-center gap-3 flex-wrap",children:[a(je,{value:o,onValueChange:m,children:[e(le,{className:"w-32",children:e(Ie,{placeholder:"所有级别"})}),a(oe,{children:[e(J,{value:"all",children:"所有级别"}),e(J,{value:"info",children:"Info"}),e(J,{value:"warn",children:"Warn"}),e(J,{value:"error",children:"Error"})]})]}),a("div",{className:"flex items-center gap-2",children:[e(rt,{id:"auto-scroll",checked:u,onCheckedChange:h=>S(h)}),e("label",{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"自动滚动"})]})]}),a("div",{className:"flex gap-2",children:[a(I,{variant:"outline",size:"sm",onClick:()=>$(7),children:[e(fe,{className:"w-3.5 h-3.5 mr-1"}),"清理7天前"]}),a(I,{variant:"outline",size:"sm",onClick:()=>$(void 0,5e3),children:[e(fe,{className:"w-3.5 h-3.5 mr-1"}),"保留5000条"]}),a(I,{variant:"outline",size:"sm",onClick:()=>j(),children:[e(Pt,{className:"w-3.5 h-3.5 mr-1"}),"刷新"]})]})]})}),e(w,{children:e(k,{className:"p-4",children:a("div",{className:"max-h-[600px] overflow-y-auto rounded-md bg-muted/30 p-2 space-y-1.5",children:[i?a(V,{variant:"destructive",children:[e(H,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",i]})]}):r.length===0?a("div",{className:"flex flex-col items-center gap-3 py-12",children:[e(be,{className:"w-12 h-12 text-muted-foreground/30"}),e("span",{className:"text-sm text-muted-foreground",children:"暂无日志"})]}):r.map((h,p)=>{const x=D(h.level);return a("div",{className:f("p-3 rounded-md bg-background border-l-[3px]",x.border),children:[a("div",{className:"flex items-center gap-2 mb-1",children:[a(y,{variant:x.badge,className:"gap-1 text-[10px] px-1.5 py-0",children:[x.icon," ",h.level.toUpperCase()]}),e("span",{className:"text-[11px] text-muted-foreground",children:new Date(h.timestamp).toLocaleString()}),h.source&&e(y,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:h.source})]}),e("p",{className:"text-sm font-mono whitespace-pre-wrap break-words",children:h.message})]},`${h.timestamp}-${p}`)}),e("div",{ref:v})]})})})]})}function ea({onSuccess:r}){const[t,s]=N(""),[n,c]=N(""),[l,i]=N(!1),d=$e(async()=>{const o=t.trim();if(!o){c("请输入 Token");return}i(!0),c("");try{const m=await fetch("/api/system/status",{headers:{Authorization:`Bearer ${o}`}});m.ok?(Nr(o),r()):m.status===401?c("Token 无效,请检查后重试"):c(`验证失败 (HTTP ${m.status})`)}catch{c("无法连接到服务器")}finally{i(!1)}},[t,r]);return e("div",{className:"flex items-center justify-center min-h-screen bg-background",children:a(w,{className:f("w-full max-w-md mx-4"),children:[a(E,{className:"text-center space-y-2",children:[e("div",{className:"flex items-center justify-center mx-auto w-12 h-12 rounded-xl bg-foreground text-background font-bold text-xl",children:"Z"}),e(L,{className:"text-xl",children:"Zhin.js 控制台"}),e(Z,{children:"请输入 API Token 以访问管理面板"})]}),e(k,{children:a("form",{onSubmit:o=>{o.preventDefault(),d()},className:"space-y-4",children:[a("div",{className:"space-y-2",children:[e(_,{type:"password",placeholder:"API Token",value:t,onChange:o=>{s(o.target.value),n&&c("")},autoFocus:!0}),n&&e("p",{className:"text-sm text-destructive",children:n})]}),e(I,{type:"submit",className:"w-full",disabled:l,children:l?"验证中...":"登录"}),a("p",{className:"text-xs text-center text-muted-foreground",children:["Token 位于 ",e("code",{className:"text-xs bg-muted px-1 rounded",children:".env"})," 文件的"," ",e("code",{className:"text-xs bg-muted px-1 rounded",children:"HTTP_TOKEN"})," 中"]})]})})]})})}function ee(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ee=function(s){return typeof s}:ee=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ee(r)}function ta(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function ra(r,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function aa(r,t,s){return t&&ra(r.prototype,t),r}function sa(r,t){return t&&(ee(t)==="object"||typeof t=="function")?t:te(r)}function pe(r){return pe=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},pe(r)}function te(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function na(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&ge(r,t)}function ge(r,t){return ge=Object.setPrototypeOf||function(n,c){return n.__proto__=c,n},ge(r,t)}function re(r,t,s){return t in r?Object.defineProperty(r,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[t]=s,r}var at=(function(r){na(t,r);function t(){var s,n;ta(this,t);for(var c=arguments.length,l=new Array(c),i=0;i<c;i++)l[i]=arguments[i];return n=sa(this,(s=pe(t)).call.apply(s,[this].concat(l))),re(te(n),"state",{bootstrapped:!1}),re(te(n),"_unsubscribe",void 0),re(te(n),"handlePersistorState",function(){var d=n.props.persistor,o=d.getState(),m=o.bootstrapped;m&&(n.props.onBeforeLift?Promise.resolve(n.props.onBeforeLift()).finally(function(){return n.setState({bootstrapped:!0})}):n.setState({bootstrapped:!0}),n._unsubscribe&&n._unsubscribe())}),n}return aa(t,[{key:"componentDidMount",value:function(){this._unsubscribe=this.props.persistor.subscribe(this.handlePersistorState),this.handlePersistorState()}},{key:"componentWillUnmount",value:function(){this._unsubscribe&&this._unsubscribe()}},{key:"render",value:function(){return typeof this.props.children=="function"?this.props.children(this.state.bootstrapped):this.state.bootstrapped?this.props.children:this.props.loading}}]),t})(dt);re(at,"defaultProps",{children:null,loading:null});const ca=Q.Provider;Q.Root;Q.Trigger;const la=g.forwardRef(({className:r,sideOffset:t=4,...s},n)=>e(Q.Portal,{children:e(Q.Content,{ref:n,sideOffset:t,className:f("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r),...s})}));la.displayName="TooltipContent";fr();function oa(){const[r,t]=N(vr()),s=$e(()=>t(!0),[]);return F(()=>{const n=()=>t(!1);return window.addEventListener("zhin:auth-required",n),()=>window.removeEventListener("zhin:auth-required",n)},[]),r?e(at,{loading:null,persistor:Ut,children:e(ur,{store:Jt,children:e(ia,{})})}):e(ea,{onSuccess:s})}function ia(){Wt();const r=W(i=>i.script.entries),t=W(i=>i.script.loadedScripts),s=W(i=>i.script.synced),[n,c]=N(!1);F(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:e(yr,{}),meta:{order:0},children:[{key:"dashboard-home",path:"/dashboard",title:"系统概览",icon:e($t,{className:"w-4 h-4"}),element:e(Rr,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:e(z,{className:"w-4 h-4"}),element:e(Tr,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:e(Zr,{}),meta:{hideInMenu:!0}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:e(X,{className:"w-4 h-4"}),element:e(Yr,{}),meta:{order:3}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:e(be,{className:"w-4 h-4"}),element:e(Qr,{}),meta:{order:4}}]}].forEach(d=>{qt(d)}),c(!0)},[]);const l=s&&(r.length===0||r.length===t.length);return!n||!l?e("div",{className:"flex items-center justify-center h-screen bg-background",children:a("div",{className:"text-center",children:[e("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-2 border-muted-foreground border-t-foreground"}),a("p",{className:"mt-3 text-sm text-muted-foreground",children:["加载中... (",t.length,"/",r.length,")"]})]})}):e(Ht,{})}ut(document.getElementById("root")).render(e(mt,{children:e(ca,{children:e(oa,{})})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/console",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"description": "Web console service for Zhin.js with real-time monitoring",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@types/ws": "^8.18.1",
|
|
74
74
|
"@zhin.js/client": "^1.0.10",
|
|
75
|
-
"@zhin.js/
|
|
75
|
+
"@zhin.js/core": "^1.0.42",
|
|
76
76
|
"zhin.js": "1.0.42",
|
|
77
|
-
"@zhin.js/
|
|
77
|
+
"@zhin.js/http": "^1.0.36"
|
|
78
78
|
},
|
|
79
79
|
"files": [
|
|
80
80
|
"lib",
|