@zhin.js/console 1.0.11 → 1.0.13
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 +14 -0
- package/client/src/pages/dashboard-plugin-detail.tsx +33 -5
- package/dist/index.js +6 -6
- package/lib/bin.d.ts +0 -2
- package/lib/bin.js +101 -15
- package/lib/build.d.ts +4 -2
- package/lib/build.js +83 -83
- package/lib/dev.d.ts +6 -4
- package/lib/dev.js +72 -69
- package/lib/index.d.ts +7 -5
- package/lib/index.js +181 -159
- package/lib/websocket.d.ts +9 -5
- package/lib/websocket.js +71 -78
- package/package.json +20 -15
- package/lib/bin.d.ts.map +0 -1
- package/lib/bin.js.map +0 -1
- package/lib/build.d.ts.map +0 -1
- package/lib/build.js.map +0 -1
- package/lib/dev.d.ts.map +0 -1
- package/lib/dev.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/websocket.d.ts.map +0 -1
- package/lib/websocket.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @zhin.js/console
|
|
2
2
|
|
|
3
|
+
## 1.0.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3bc5d56: fix: 内存优化
|
|
8
|
+
- Updated dependencies [3bc5d56]
|
|
9
|
+
- @zhin.js/core@1.0.17
|
|
10
|
+
|
|
11
|
+
## 1.0.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 9bc8dc4: fix: remove log,find client
|
|
16
|
+
|
|
3
17
|
## 1.0.11
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -13,6 +13,10 @@ interface PluginDetail {
|
|
|
13
13
|
description: string
|
|
14
14
|
commands: Array<{
|
|
15
15
|
name: string
|
|
16
|
+
desc?: string[]
|
|
17
|
+
usage?: string[]
|
|
18
|
+
examples?: string[]
|
|
19
|
+
help?: string
|
|
16
20
|
}>
|
|
17
21
|
components: Array<{
|
|
18
22
|
name: string
|
|
@@ -210,11 +214,35 @@ export default function DashboardPluginDetail() {
|
|
|
210
214
|
<Separator size="4" />
|
|
211
215
|
<Flex direction="column" gap="2" className="max-h-60 overflow-y-auto">
|
|
212
216
|
{plugin.commands.map((cmd, index) => (
|
|
213
|
-
<Box key={index} className="rounded-lg bg-gray-50 dark:bg-gray-900 p-
|
|
214
|
-
<Flex direction="column" gap="
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
<Box key={index} className="rounded-lg bg-gray-50 dark:bg-gray-900 p-3">
|
|
218
|
+
<Flex direction="column" gap="2">
|
|
219
|
+
<Code size="2" weight="bold">{cmd.name}</Code>
|
|
220
|
+
|
|
221
|
+
{cmd.desc && cmd.desc.length > 0 && (
|
|
222
|
+
<Flex direction="column" gap="1">
|
|
223
|
+
{cmd.desc.map((desc, i) => (
|
|
224
|
+
<Text key={i} size="1" color="gray">{desc}</Text>
|
|
225
|
+
))}
|
|
226
|
+
</Flex>
|
|
227
|
+
)}
|
|
228
|
+
|
|
229
|
+
{cmd.usage && cmd.usage.length > 0 && (
|
|
230
|
+
<Flex direction="column" gap="1">
|
|
231
|
+
<Text size="1" weight="bold" color="blue">用法:</Text>
|
|
232
|
+
{cmd.usage.map((usage, i) => (
|
|
233
|
+
<Code key={i} size="1" variant="soft">{usage}</Code>
|
|
234
|
+
))}
|
|
235
|
+
</Flex>
|
|
236
|
+
)}
|
|
237
|
+
|
|
238
|
+
{cmd.examples && cmd.examples.length > 0 && (
|
|
239
|
+
<Flex direction="column" gap="1">
|
|
240
|
+
<Text size="1" weight="bold" color="green">示例:</Text>
|
|
241
|
+
{cmd.examples.map((example, i) => (
|
|
242
|
+
<Code key={i} size="1" variant="soft" color="green">{example}</Code>
|
|
243
|
+
))}
|
|
244
|
+
</Flex>
|
|
245
|
+
)}
|
|
218
246
|
</Flex>
|
|
219
247
|
</Box>
|
|
220
248
|
))}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r,Fragment as me}from"./react-jsx-runtime.js";import*as G from"./react.js";import nr,{useState as
|
|
1
|
+
import{jsx as e,jsxs as r,Fragment as me}from"./react-jsx-runtime.js";import*as G from"./react.js";import nr,{useState as z,useEffect as q,useMemo as tr,useRef as ir,PureComponent as ar,StrictMode as lr}from"./react.js";import{createRoot as or}from"./react-dom-client.js";import{Moon as cr,Sun as sr,Menu as dr,Search as hr,Bell as ur,User as gr,Users as mr,BarChart3 as pr,HelpCircle as br,LogOut as fr,AlertCircle as te,Package as K,Bot as ce,Activity as ke,TrendingUp as yr,Clock as Ce,Cpu as vr,MemoryStick as ye,FileText as se,Terminal as Se,Box as Je,Layers as pe,Database as je,Code as He,Info as be,Lock as wr,Calendar as zr,List as Ge,Trash2 as Re,Plus as xr,GitBranch as Nr,Settings as kr,ChevronDown as Cr,CheckCircle as Sr,X as jr,Save as Rr,ArrowLeft as Le,Wifi as Ir,WifiOff as $r,Zap as Or,RefreshCw as Tr,Circle as Fr,XCircle as Lr,AlertTriangle as Pr,Home as Er}from"./lucide-react.js";import{useDispatch as Br,useWebSocket as Ar,useSelector as le,cn as de,Link as _r,setActiveMenu as Mr,toggleSidebar as Dr,Outlet as Vr,useConfig as Ur,persistor as Wr,store as Jr,addPage as Hr,DynamicRouter as Gr}from"./client.js";import{Avatar as re,DropdownMenu as W,Accordion as ae}from"./radix-ui.js";import*as Te from"./radix-ui-themes.js";import{Flex as l,Box as I,Spinner as fe,Text as s,Callout as F,Heading as _,Grid as oe,Card as S,Badge as j,Button as U,TextArea as Q,TextField as E,Switch as qe,Select as T,Separator as Ie,Checkbox as qr,Theme as Zr}from"./radix-ui-themes.js";import{useNavigate as Fe,useParams as Kr}from"./react-router.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&a(h)}).observe(document,{childList:!0,subtree:!0});function i(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(o){if(o.ep)return;o.ep=!0;const c=i(o);fetch(o.href,c)}})();var ve={exports:{}},we={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-with-selector.production.js
|
|
4
4
|
*
|
|
@@ -6,10 +6,10 @@ import{jsx as e,jsxs as r,Fragment as me}from"./react-jsx-runtime.js";import*as
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Pe;function Xr(){if(Pe)return we;Pe=1;var n=nr;function t(d,g){return d===g&&(d!==0||1/d===1/g)||d!==d&&g!==g}var i=typeof Object.is=="function"?Object.is:t,a=n.useSyncExternalStore,o=n.useRef,c=n.useEffect,h=n.useMemo,u=n.useDebugValue;return we.useSyncExternalStoreWithSelector=function(d,g,b,z,v){var R=o(null);if(R.current===null){var x={hasValue:!1,value:null};R.current=x}else x=R.current;R=h(function(){function B(f){if(!M){if(M=!0,D=f,f=z(f),v!==void 0&&x.hasValue){var y=x.value;if(v(y,f))return A=y}return A=f}if(y=A,i(D,f))return y;var $=z(f);return v!==void 0&&v(y,$)?(D=f,y):(D=f,A=$)}var M=!1,D,A,m=b===void 0?null:b;return[function(){return B(g())},m===null?void 0:function(){return B(m())}]},[g,b,z,v]);var N=a(d,R[0],R[1]);return c(function(){x.hasValue=!0,x.value=N},[N]),u(N),N},we}var Ee;function Yr(){return Ee||(Ee=1,ve.exports=Xr()),ve.exports}Yr();function Qr(n){n()}function en(){let n=null,t=null;return{clear(){n=null,t=null},notify(){Qr(()=>{let i=n;for(;i;)i.callback(),i=i.next})},get(){const i=[];let a=n;for(;a;)i.push(a),a=a.next;return i},subscribe(i){let a=!0;const o=t={callback:i,next:null,prev:t};return o.prev?o.prev.next=o:n=o,function(){!a||n===null||(a=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:n=o.next)}}}}var Be={notify(){},get:()=>[]};function rn(n,t){let i,a=Be,o=0,c=!1;function h(N){b();const B=a.subscribe(N);let M=!1;return()=>{M||(M=!0,B(),z())}}function u(){a.notify()}function d(){x.onStateChange&&x.onStateChange()}function g(){return c}function b(){o++,i||(i=n.subscribe(d),a=en())}function z(){o--,i&&o===0&&(i(),i=void 0,a.clear(),a=Be)}function v(){c||(c=!0,b())}function R(){c&&(c=!1,z())}const x={addNestedSub:h,notifyNestedSubs:u,handleChangeWrapper:d,isSubscribed:g,trySubscribe:v,tryUnsubscribe:R,getListeners:()=>a};return x}var nn=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",tn=nn(),an=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ln=an(),on=()=>tn||ln?G.useLayoutEffect:G.useEffect,cn=on(),sn=Symbol.for("react-redux-context"),dn=typeof globalThis<"u"?globalThis:{};function hn(){if(!G.createContext)return{};const n=dn[sn]??=new Map;let t=n.get(G.createContext);return t||(t=G.createContext(null),n.set(G.createContext,t)),t}var un=hn();function gn(n){const{children:t,context:i,serverState:a,store:o}=n,c=G.useMemo(()=>{const d=rn(o);return{store:o,subscription:d,getServerState:a?()=>a:void 0}},[o,a]),h=G.useMemo(()=>o.getState(),[o]);cn(()=>{const{subscription:d}=c;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),h!==o.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[c,h]);const u=i||un;return G.createElement(u.Provider,{value:c},t)}var mn=gn;const pn={light:{background:"0 0% 100%",foreground:"222.2 84% 4.9%",card:"0 0% 100%","card-foreground":"222.2 84% 4.9%",popover:"0 0% 100%","popover-foreground":"222.2 84% 4.9%",primary:"221.2 83.2% 53.3%","primary-foreground":"210 40% 98%",secondary:"210 40% 96.1%","secondary-foreground":"222.2 47.4% 11.2%",muted:"210 40% 96.1%","muted-foreground":"215.4 16.3% 46.9%",accent:"210 40% 96.1%","accent-foreground":"222.2 47.4% 11.2%",destructive:"0 84.2% 60.2%","destructive-foreground":"210 40% 98%",border:"214.3 31.8% 91.4%",input:"214.3 31.8% 91.4%",ring:"221.2 83.2% 53.3%",radius:"0.5rem"},dark:{background:"222.2 84% 4.9%",foreground:"210 40% 98%",card:"222.2 84% 4.9%","card-foreground":"210 40% 98%",popover:"222.2 84% 4.9%","popover-foreground":"210 40% 98%",primary:"217.2 91.2% 59.8%","primary-foreground":"222.2 47.4% 11.2%",secondary:"217.2 32.6% 17.5%","secondary-foreground":"210 40% 98%",muted:"217.2 32.6% 17.5%","muted-foreground":"215 20.2% 65.1%",accent:"217.2 32.6% 17.5%","accent-foreground":"210 40% 98%",destructive:"0 62.8% 30.6%","destructive-foreground":"210 40% 98%",border:"217.2 32.6% 17.5%",input:"217.2 32.6% 17.5%",ring:"224.3 76.3% 48%",radius:"0.5rem"}};function Ze(n){const t=document.documentElement,i=pn[n];t.classList.remove("light","dark"),t.classList.add(n),Object.entries(i).forEach(([a,o])=>{t.style.setProperty(`--${a}`,o)}),localStorage.setItem("theme",n)}function Ke(){const n=localStorage.getItem("theme");return n&&(n==="light"||n==="dark")?n:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function bn(){const n=Ke();return Ze(n),n}function fn(){const[n,t]=w(Ke);return q(()=>{Ze(n)},[n]),{theme:n,setTheme:t,toggleTheme:()=>{t(a=>a==="light"?"dark":"light")}}}function yn(){const{theme:n,toggleTheme:t}=fn();return e("button",{onClick:t,className:"p-2 hover:bg-accent rounded-lg transition-colors text-foreground",title:n==="light"?"切换到暗色模式":"切换到亮色模式",children:n==="light"?e(cr,{className:"w-5 h-5"}):e(sr,{className:"w-5 h-5"})})}const{Box:re,Flex:k,Text:J,Heading:Ae,IconButton:_e,Badge:vn,TextField:wn,ScrollArea:zn,Container:xn}=Te;function Nn(){const n=Br();Ar();const t=le(c=>c.ui.sidebarOpen),i=le(c=>c.ui.activeMenu),a=le(c=>c.route.routes),o=tr(()=>{const c=a.find(h=>h.key==="dashboard-layout");return!c||!c.children?[]:c.children.filter(h=>!h.meta?.hideInMenu&&h.key!=="dashboard-layout").map((h,u)=>({key:h.key||`menu-item-${u}`,title:h.title,index:h.index,icon:h.icon,href:h.path}))},[a]);return r(k,{className:"h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800",children:[r(k,{direction:"column",className:de("glass transition-all duration-300 shadow-xl border-r border-gray-200/50 dark:border-gray-700/50",t?"w-64":"w-20"),children:[e(re,{p:"4",className:"border-b border-gray-200/50 dark:border-gray-700/50",children:r(k,{align:"center",className:de("transition-all duration-300",t?"gap-3":"justify-center"),children:[e(k,{align:"center",justify:"center",className:"w-11 min-w-11 h-11 rounded-xl shadow-md bg-gradient-to-br from-blue-500 to-purple-600",children:e(J,{size:"5",weight:"bold",className:"text-white",children:"Z"})}),t&&r(k,{direction:"column",gap:"0",children:[e(Ae,{size:"4",className:"text-gray-900 dark:text-gray-100",children:"Zhin.js"}),e(J,{size:"1",color:"gray",children:"管理控制台"})]})]})}),e(zn,{className:"flex-1",scrollbars:"vertical",children:e(re,{p:"3",children:e(k,{direction:"column",gap:"2",children:o.map(c=>{const h=i===c.key;return r(_r,{to:c.href,onClick:()=>n(Mr(c.key)),className:de("menu-item",h&&"active"),children:[e("div",{className:"icon",children:c.icon}),t&&e("div",{className:"text",children:e("div",{className:"title",children:c.title})}),h&&t&&e("div",{className:"indicator"})]},c.key)})})})}),e(k,{p:"3",className:"border-t border-gray-200/50 dark:border-gray-700/50 flex-shrink-0",children:r(k,{align:"center",gap:"2",p:"2",className:de("rounded-xl bg-gray-50/50 dark:bg-gray-800/50 transition-all duration-200 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700",!t&&"justify-center"),children:[r(ee.Root,{className:"w-8 h-8 min-w-8 border-2 border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e(ee.Image,{src:"https://i.pravatar.cc/150?u=admin",alt:"管理员"}),e(ee.Fallback,{children:"管"})]}),t&&r(k,{direction:"column",gap:"0",className:"flex-1 min-w-0",children:[e(J,{size:"2",weight:"medium",className:"truncate text-gray-900 dark:text-gray-100",children:"管理员"}),e(J,{size:"1",color:"gray",className:"truncate",children:"admin@zhin.com"})]})]})})]}),r(k,{direction:"column",className:"flex-1 overflow-hidden",children:[e(re,{className:"glass border-b border-gray-200/50 dark:border-gray-700/50 shadow-sm",children:r(k,{justify:"between",align:"center",px:"4",className:"h-16",children:[r(k,{align:"center",gap:"3",children:[e(_e,{variant:"ghost",size:"2",onClick:()=>n(Dr()),className:"hover-lift rounded-xl",children:e(dr,{className:"w-5 h-5"})}),r(k,{direction:"column",gap:"0",children:[e(Ae,{size:"3",className:"text-gray-900 dark:text-gray-100",children:"控制台"}),e(J,{size:"1",color:"gray",children:"欢迎回来!"})]})]}),e(k,{className:"hidden md:flex flex-1 max-w-xl mx-6",children:r(re,{className:"relative",children:[e(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500"}),e(wn.Root,{placeholder:"搜索功能、用户、设置...",size:"2",className:"w-full pl-10"})]})}),r(k,{align:"center",gap:"2",children:[e(yn,{}),r(re,{className:"relative",children:[e(_e,{variant:"ghost",size:"2",className:"hover-lift rounded-xl",children:e(ur,{className:"w-5 h-5"})}),e(vn,{color:"red",variant:"solid",size:"1",className:"absolute -top-1 -right-1 min-w-5 h-5 flex items-center justify-center p-0",children:"3"})]}),r(W.Root,{children:[e(W.Trigger,{asChild:!0,children:r(k,{align:"center",gap:"2",px:"2",py:"1",className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 transition-all duration-200 rounded-xl",children:[r(ee.Root,{className:"w-8 h-8 border-2 border-blue-500/20 dark:border-blue-400/30",children:[e(ee.Image,{src:"https://i.pravatar.cc/150?u=admin",alt:"管理员"}),e(ee.Fallback,{children:"管"})]}),r(k,{direction:"column",gap:"0",className:"hidden lg:flex",children:[e(J,{size:"2",weight:"medium",className:"text-gray-900 dark:text-gray-100",children:"管理员"}),e(J,{size:"1",color:"gray",children:"admin@zhin.com"})]})]})}),r(W.Content,{align:"end",className:"min-w-56",children:[r(re,{p:"3",className:"border-b border-gray-200 dark:border-gray-700",children:[e(J,{size:"2",weight:"bold",className:"block",children:"登录为"}),e(J,{size:"1",color:"gray",className:"block",children:"admin@zhin.com"})]}),r(W.Item,{children:[e(gr,{className:"mr-2 h-4 w-4"}),"我的设置"]}),r(W.Item,{children:[e(mr,{className:"mr-2 h-4 w-4"}),"团队设置"]}),r(W.Item,{children:[e(pr,{className:"mr-2 h-4 w-4"}),"数据分析"]}),r(W.Item,{children:[e(br,{className:"mr-2 h-4 w-4"}),"帮助与反馈"]}),e(W.Separator,{}),r(W.Item,{color:"red",children:[e(fr,{className:"mr-2 h-4 w-4"}),"退出登录"]})]})]})]})]})}),e(k,{className:"flex-1 overflow-auto",children:e(xn,{size:"4",p:"6",children:e(Vr,{})})})]})]})}function kn(){const n=Fe(),[t,i]=w(null),[a,o]=w(null),[c,h]=w(!0),[u,d]=w(null);q(()=>{g();const v=setInterval(g,5e3);return()=>clearInterval(v)},[]);const g=async()=>{try{const[v,R]=await Promise.all([fetch("/api/stats",{credentials:"include"}),fetch("/api/system/status",{credentials:"include"})]);if(!v.ok||!R.ok)throw new Error("API 请求失败");const x=await v.json(),N=await R.json();x.success&&N.success&&(i(x.data),o(N.data),d(null))}catch(v){d(v.message)}finally{h(!1)}},b=v=>{const R=Math.floor(v/86400),x=Math.floor(v%86400/3600),N=Math.floor(v%3600/60);return`${R}天 ${x}小时 ${N}分钟`},z=v=>`${(v/1024/1024).toFixed(2)} MB`;return c?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):u?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",u]})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"6",children:[e(_,{size:"8",children:"系统概览"}),e(s,{color:"gray",children:"实时监控您的机器人框架运行状态"})]}),r(oe,{columns:{initial:"1",sm:"2",lg:"4"},gap:"4",mb:"6",children:[e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"插件总数"}),e(I,{p:"2",style:{borderRadius:"8px",backgroundColor:"var(--purple-3)"},children:e(Z,{size:16,color:"var(--purple-9)"})})]}),e(_,{size:"7",children:t?.plugins.total||0}),r(l,{align:"center",gap:"1",children:[e(j,{color:"blue",children:t?.plugins.active||0}),e(s,{size:"1",color:"gray",children:"个活跃"})]})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"机器人"}),e(ce,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.bots.total||0}),r(s,{size:"1",color:"green",children:[t?.bots.online||0," 个在线"]})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"命令数量"}),e(ke,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.commands||0}),e(s,{size:"1",color:"gray",children:"可用命令"})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"组件数量"}),e(yr,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.components||0}),e(s,{size:"1",color:"gray",children:"已注册组件"})]})})]}),r(oe,{columns:{initial:"1",md:"2"},gap:"4",mb:"6",children:[e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"系统信息"}),e(s,{size:"2",color:"gray",children:"服务器运行状态"})]}),r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(Ce,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"运行时间"})]}),e(j,{variant:"soft",children:a?b(a.uptime):"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(vr,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"平台"})]}),e(j,{variant:"soft",children:a?.platform||"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ke,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"Node 版本"})]}),e(j,{variant:"soft",children:a?.nodeVersion||"-"})]})]})]})}),e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"资源使用"}),e(s,{size:"2",color:"gray",children:"内存使用情况"})]}),r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"堆内存使用"})]}),e(j,{variant:"soft",children:t?`${t.memory.toFixed(2)} MB`:"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"总堆内存"})]}),e(j,{variant:"soft",children:a?z(a.memory.heapTotal):"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"RSS"})]}),e(j,{variant:"soft",children:a?z(a.memory.rss):"-"})]})]})]})})]}),e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"快速操作"}),e(s,{size:"2",color:"gray",children:"常用功能快捷入口"})]}),r(oe,{columns:{initial:"1",md:"3"},gap:"3",children:[e(U,{variant:"outline",onClick:()=>n("/plugins"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(Z,{size:20,color:"var(--blue-9)"}),e(s,{weight:"medium",children:"插件管理"}),e(s,{size:"1",color:"gray",children:"查看和管理插件"})]})}),e(U,{variant:"outline",onClick:()=>n("/bots"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(ce,{size:20,color:"var(--green-9)"}),e(s,{weight:"medium",children:"机器人状态"}),e(s,{size:"1",color:"gray",children:"监控机器人运行"})]})}),e(U,{variant:"outline",onClick:()=>n("/logs"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(se,{size:20,color:"var(--purple-9)"}),e(s,{weight:"medium",children:"系统日志"}),e(s,{size:"1",color:"gray",children:"查看运行日志"})]})})]})]})})]})}const{Flex:O,Box:Cn,Spinner:Sn,Text:L,Callout:ze,Heading:xe,Badge:Me,Grid:De,Card:Ve,Separator:jn}=Te;function Rn(){const n=Fe(),[t,i]=w([]),[a,o]=w(!0),[c,h]=w(null);q(()=>{u();const d=setInterval(u,1e4);return()=>clearInterval(d)},[]);const u=async()=>{try{const d=await fetch("/api/plugins",{credentials:"include"});if(!d.ok)throw new Error("API 请求失败");const g=await d.json();if(g.success)i(g.data),h(null);else throw new Error("数据格式错误")}catch(d){h(d.message)}finally{o(!1)}};return a?e(O,{align:"center",justify:"center",className:"h-full",children:r(O,{direction:"column",align:"center",gap:"3",children:[e(Sn,{size:"3"}),e(L,{size:"2",color:"gray",children:"加载中..."})]})}):c?e(O,{align:"center",justify:"center",className:"h-full",children:r(ze.Root,{color:"red",children:[e(ze.Icon,{children:e(te,{})}),r(ze.Text,{children:["加载失败: ",c]})]})}):r(Cn,{children:[r(O,{direction:"column",gap:"2",mb:"4",children:[e(xe,{size:"6",children:"插件管理"}),r(O,{align:"center",gap:"2",children:[r(L,{size:"2",color:"gray",children:["共 ",t.length," 个插件"]}),e(Me,{color:"green",size:"1",children:t.filter(d=>d.status==="active").length}),e(L,{size:"2",color:"gray",children:"个运行中"})]})]}),e(De,{columns:{initial:"1",sm:"2",lg:"3"},gap:"3",children:t.map((d,g)=>e(Ve,{className:"cursor-pointer hover-lift transition-smooth",onClick:()=>n(`/plugins/${encodeURIComponent(d.name)}`),children:r(O,{direction:"column",gap:"2",p:"2",children:[r(O,{justify:"between",align:"center",children:[r(O,{align:"center",gap:"2",children:[e(O,{align:"center",justify:"center",className:"w-8 h-8 rounded-lg bg-blue-500/10 dark:bg-blue-400/10",children:e(Z,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e(xe,{size:"3",children:d.name})]}),e(Me,{color:d.status==="active"?"green":"gray",size:"1",children:d.status==="active"?"运行中":"已停止"})]}),e(L,{size:"1",color:"gray",className:"line-clamp-2",children:d.description||"暂无描述"}),e(jn,{size:"4",my:"1"}),r(De,{columns:{initial:"1",sm:"2",lg:"4"},gap:"1",children:[r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-blue-500/5 dark:bg-blue-400/5 p-1.5",children:[e(Se,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.commandCount}),e(L,{size:"1",color:"gray",children:"命令"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-green-500/5 dark:bg-green-400/5 p-1.5",children:[e(Je,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.componentCount}),e(L,{size:"1",color:"gray",children:"组件"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-purple-500/5 dark:bg-purple-400/5 p-1.5",children:[e(pe,{className:"w-3 h-3 text-purple-600 dark:text-purple-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.middlewareCount}),e(L,{size:"1",color:"gray",children:"中间件"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-orange-500/5 dark:bg-orange-400/5 p-1.5",children:[e(je,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.contextCount}),e(L,{size:"1",color:"gray",children:"上下文"})]})]})]})},`${d.name}-${g}`))}),t.length===0&&e(Ve,{className:"mt-6",children:r(O,{direction:"column",align:"center",gap:"3",py:"8",children:[e(O,{align:"center",justify:"center",className:"w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-800",children:e(Z,{className:"w-8 h-8 text-gray-400"})}),r(O,{direction:"column",align:"center",gap:"1",children:[e(xe,{size:"4",children:"暂无插件"}),e(L,{size:"2",color:"gray",children:"请先安装并启用插件"})]})]})})]})}function In({field:n,value:t,onChange:i}){return n.enum?r(T.Root,{size:"2",value:t?.toString()||"",onValueChange:i,children:[e(T.Trigger,{className:"w-full hover:border-blue-500 dark:hover:border-blue-400 transition-colors"}),e(T.Content,{className:"shadow-lg",children:n.enum.map(a=>e(T.Item,{value:a.toString(),className:"hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",children:a.toString()},a))})]}):n.description?.includes("多行")||n.key?.includes("description")?e(Y,{size:"2",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入",rows:3,className:"font-sans resize-y hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus:ring-2 focus:ring-blue-500/20"}):e(E.Root,{size:"2",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"})}function $n({field:n,value:t,onChange:i}){return e(E.Root,{size:"2",type:"number",value:t?.toString()||"",onChange:a=>i(parseFloat(a.target.value)||0),placeholder:n.description||"请输入数字",min:n.min,max:n.max,className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"})}function On({value:n,onChange:t}){return r(l,{align:"center",gap:"3",className:"p-3 rounded-lg bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-800",children:[e(qe,{size:"2",checked:n===!0,onCheckedChange:t,className:"cursor-pointer"}),r(l,{direction:"column",gap:"1",children:[e(s,{size:"2",weight:"bold",color:n?"green":"gray",children:n?"已启用":"已禁用"}),e(s,{size:"1",color:"gray",children:n?"功能当前处于开启状态":"功能当前处于关闭状态"})]})]})}function Tn({field:n,value:t,onChange:i}){const a=typeof t=="number"?t:n.default||0;return e("div",{className:"p-4 rounded-lg bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 border border-blue-200 dark:border-blue-800",children:r(l,{direction:"column",gap:"3",children:[r(l,{align:"center",gap:"3",children:[e("input",{type:"range",min:n.min||0,max:n.max||1,step:n.step||.01,value:a,onChange:o=>i(parseFloat(o.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-blue-200 dark:bg-blue-800 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-blue-600 dark:[&::-webkit-slider-thumb]:bg-blue-400 [&::-webkit-slider-thumb]:cursor-pointer hover:[&::-webkit-slider-thumb]:bg-blue-700 dark:hover:[&::-webkit-slider-thumb]:bg-blue-300 transition-all"}),e(E.Root,{size:"2",type:"number",value:(a*100).toFixed(0),onChange:o=>i(parseFloat(o.target.value)/100),min:(n.min||0)*100,max:(n.max||1)*100,className:"w-24",children:e(E.Slot,{side:"right",children:e(s,{size:"1",weight:"bold",className:"text-blue-600 dark:text-blue-400",children:"%"})})})]}),r(l,{align:"center",justify:"between",children:[e(s,{size:"1",color:"gray",children:"当前值"}),r(j,{color:"blue",size:"2",variant:"soft",className:"font-mono",children:[(a*100).toFixed(1),"%"]})]})]})})}function Fn({field:n,value:t,onChange:i}){const a=t instanceof Date?t.toISOString().split("T")[0]:t||"";return e("div",{className:"relative",children:e(E.Root,{size:"2",type:"date",value:a,onChange:o=>i(new Date(o.target.value)),placeholder:n.description||"选择日期",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20",children:e(E.Slot,{side:"left",children:e(zr,{className:"w-4 h-4 text-gray-500"})})})})}function Ln({field:n,value:t,onChange:i}){const a=t instanceof RegExp?t.source:typeof t=="string"?t:"";return e("div",{className:"p-3 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800",children:r(l,{direction:"column",gap:"2",children:[r(E.Root,{size:"2",value:a,onChange:o=>{try{i(new RegExp(o.target.value))}catch{i(o.target.value)}},placeholder:n.description||"请输入正则表达式",className:"font-mono text-sm hover:border-amber-500 dark:hover:border-amber-400 transition-colors",children:[e(E.Slot,{side:"left",children:e(s,{size:"1",className:"text-amber-600 dark:text-amber-400 font-bold",children:"/"})}),e(E.Slot,{side:"right",children:e(s,{size:"1",className:"text-amber-600 dark:text-amber-400 font-bold",children:"/"})})]}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-amber-600 dark:text-amber-400"}),e(s,{size:"1",className:"text-amber-700 dark:text-amber-300",children:"输入正则表达式模式 (省略斜杠)"})]})]})})}function Pn({field:n,value:t}){const i=n.default||t;return e("div",{className:"p-3 rounded-lg bg-gray-100 dark:bg-gray-900 border border-gray-300 dark:border-gray-700",children:r(l,{align:"center",gap:"3",children:[e(wr,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),e(j,{variant:"soft",size:"2",className:"font-mono",children:String(i)}),e(s,{size:"1",color:"gray",className:"ml-auto",children:"(常量,不可修改)"})]})})}function En({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800",children:r(l,{direction:"column",gap:"3",children:[r(l,{align:"center",gap:"2",children:[e(He,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(s,{size:"1",weight:"bold",className:"text-purple-700 dark:text-purple-300",children:"JSON 格式输入"})]}),e(Y,{size:"2",value:typeof t=="object"?JSON.stringify(t,null,2):String(t||""),onChange:a=>{try{i(JSON.parse(a.target.value))}catch{i(a.target.value)}},placeholder:n.description||"支持任意类型 (JSON 格式)",rows:4,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-purple-500 dark:hover:border-purple-400 transition-colors"}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-purple-600 dark:text-purple-400"}),e(s,{size:"1",className:"text-purple-700 dark:text-purple-300",children:"支持: 字符串、数字、布尔值、对象、数组"})]})]})})}function Bn({fieldName:n,field:t,value:i,onChange:a,onArrayItemChange:o,renderNestedField:c}){const h=Array.isArray(i)?i:[],u=t.inner||t.items;return u&&["string","number"].includes(u.type)?e("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"2",children:[e(Ge,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(s,{size:"1",weight:"bold",className:"text-green-700 dark:text-green-300",children:"列表输入 (每行一个值)"})]}),e(Y,{size:"2",value:h.join(`
|
|
10
|
-
`),onChange:d=>{const
|
|
11
|
-
`).filter(Boolean),b=
|
|
12
|
-
${t.description||""}`,rows:4,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-green-500 dark:hover:border-green-400 transition-colors"})]})}):r(l,{direction:"column",gap:"2",children:[e("div",{className:"space-y-2",children:h.map((d,
|
|
9
|
+
*/var Pe;function Xr(){if(Pe)return we;Pe=1;var n=nr;function t(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var i=typeof Object.is=="function"?Object.is:t,a=n.useSyncExternalStore,o=n.useRef,c=n.useEffect,h=n.useMemo,g=n.useDebugValue;return we.useSyncExternalStoreWithSelector=function(d,u,b,w,f){var R=o(null);if(R.current===null){var N={hasValue:!1,value:null};R.current=N}else N=R.current;R=h(function(){function B(y){if(!M){if(M=!0,D=y,y=w(y),f!==void 0&&N.hasValue){var v=N.value;if(f(v,y))return A=v}return A=y}if(v=A,i(D,y))return v;var $=w(y);return f!==void 0&&f(v,$)?(D=y,v):(D=y,A=$)}var M=!1,D,A,m=b===void 0?null:b;return[function(){return B(u())},m===null?void 0:function(){return B(m())}]},[u,b,w,f]);var k=a(d,R[0],R[1]);return c(function(){N.hasValue=!0,N.value=k},[k]),g(k),k},we}var Ee;function Yr(){return Ee||(Ee=1,ve.exports=Xr()),ve.exports}Yr();function Qr(n){n()}function en(){let n=null,t=null;return{clear(){n=null,t=null},notify(){Qr(()=>{let i=n;for(;i;)i.callback(),i=i.next})},get(){const i=[];let a=n;for(;a;)i.push(a),a=a.next;return i},subscribe(i){let a=!0;const o=t={callback:i,next:null,prev:t};return o.prev?o.prev.next=o:n=o,function(){!a||n===null||(a=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:n=o.next)}}}}var Be={notify(){},get:()=>[]};function rn(n,t){let i,a=Be,o=0,c=!1;function h(k){b();const B=a.subscribe(k);let M=!1;return()=>{M||(M=!0,B(),w())}}function g(){a.notify()}function d(){N.onStateChange&&N.onStateChange()}function u(){return c}function b(){o++,i||(i=n.subscribe(d),a=en())}function w(){o--,i&&o===0&&(i(),i=void 0,a.clear(),a=Be)}function f(){c||(c=!0,b())}function R(){c&&(c=!1,w())}const N={addNestedSub:h,notifyNestedSubs:g,handleChangeWrapper:d,isSubscribed:u,trySubscribe:f,tryUnsubscribe:R,getListeners:()=>a};return N}var nn=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",tn=nn(),an=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ln=an(),on=()=>tn||ln?G.useLayoutEffect:G.useEffect,cn=on(),sn=Symbol.for("react-redux-context"),dn=typeof globalThis<"u"?globalThis:{};function hn(){if(!G.createContext)return{};const n=dn[sn]??=new Map;let t=n.get(G.createContext);return t||(t=G.createContext(null),n.set(G.createContext,t)),t}var un=hn();function gn(n){const{children:t,context:i,serverState:a,store:o}=n,c=G.useMemo(()=>{const d=rn(o);return{store:o,subscription:d,getServerState:a?()=>a:void 0}},[o,a]),h=G.useMemo(()=>o.getState(),[o]);cn(()=>{const{subscription:d}=c;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),h!==o.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[c,h]);const g=i||un;return G.createElement(g.Provider,{value:c},t)}var mn=gn;const pn={light:{background:"0 0% 100%",foreground:"222.2 84% 4.9%",card:"0 0% 100%","card-foreground":"222.2 84% 4.9%",popover:"0 0% 100%","popover-foreground":"222.2 84% 4.9%",primary:"221.2 83.2% 53.3%","primary-foreground":"210 40% 98%",secondary:"210 40% 96.1%","secondary-foreground":"222.2 47.4% 11.2%",muted:"210 40% 96.1%","muted-foreground":"215.4 16.3% 46.9%",accent:"210 40% 96.1%","accent-foreground":"222.2 47.4% 11.2%",destructive:"0 84.2% 60.2%","destructive-foreground":"210 40% 98%",border:"214.3 31.8% 91.4%",input:"214.3 31.8% 91.4%",ring:"221.2 83.2% 53.3%",radius:"0.5rem"},dark:{background:"222.2 84% 4.9%",foreground:"210 40% 98%",card:"222.2 84% 4.9%","card-foreground":"210 40% 98%",popover:"222.2 84% 4.9%","popover-foreground":"210 40% 98%",primary:"217.2 91.2% 59.8%","primary-foreground":"222.2 47.4% 11.2%",secondary:"217.2 32.6% 17.5%","secondary-foreground":"210 40% 98%",muted:"217.2 32.6% 17.5%","muted-foreground":"215 20.2% 65.1%",accent:"217.2 32.6% 17.5%","accent-foreground":"210 40% 98%",destructive:"0 62.8% 30.6%","destructive-foreground":"210 40% 98%",border:"217.2 32.6% 17.5%",input:"217.2 32.6% 17.5%",ring:"224.3 76.3% 48%",radius:"0.5rem"}};function Ze(n){const t=document.documentElement,i=pn[n];t.classList.remove("light","dark"),t.classList.add(n),Object.entries(i).forEach(([a,o])=>{t.style.setProperty(`--${a}`,o)}),localStorage.setItem("theme",n)}function Ke(){const n=localStorage.getItem("theme");return n&&(n==="light"||n==="dark")?n:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function bn(){const n=Ke();return Ze(n),n}function fn(){const[n,t]=z(Ke);return q(()=>{Ze(n)},[n]),{theme:n,setTheme:t,toggleTheme:()=>{t(a=>a==="light"?"dark":"light")}}}function yn(){const{theme:n,toggleTheme:t}=fn();return e("button",{onClick:t,className:"p-2 hover:bg-accent rounded-lg transition-colors text-foreground",title:n==="light"?"切换到暗色模式":"切换到亮色模式",children:n==="light"?e(cr,{className:"w-5 h-5"}):e(sr,{className:"w-5 h-5"})})}const{Box:ne,Flex:C,Text:J,Heading:Ae,IconButton:_e,Badge:vn,TextField:wn,ScrollArea:zn,Container:xn}=Te;function Nn(){const n=Br();Ar();const t=le(c=>c.ui.sidebarOpen),i=le(c=>c.ui.activeMenu),a=le(c=>c.route.routes),o=tr(()=>{const c=a.find(h=>h.key==="dashboard-layout");return!c||!c.children?[]:c.children.filter(h=>!h.meta?.hideInMenu&&h.key!=="dashboard-layout").map((h,g)=>({key:h.key||`menu-item-${g}`,title:h.title,index:h.index,icon:h.icon,href:h.path}))},[a]);return r(C,{className:"h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800",children:[r(C,{direction:"column",className:de("glass transition-all duration-300 shadow-xl border-r border-gray-200/50 dark:border-gray-700/50",t?"w-64":"w-20"),children:[e(ne,{p:"4",className:"border-b border-gray-200/50 dark:border-gray-700/50",children:r(C,{align:"center",className:de("transition-all duration-300",t?"gap-3":"justify-center"),children:[e(C,{align:"center",justify:"center",className:"w-11 min-w-11 h-11 rounded-xl shadow-md bg-gradient-to-br from-blue-500 to-purple-600",children:e(J,{size:"5",weight:"bold",className:"text-white",children:"Z"})}),t&&r(C,{direction:"column",gap:"0",children:[e(Ae,{size:"4",className:"text-gray-900 dark:text-gray-100",children:"Zhin.js"}),e(J,{size:"1",color:"gray",children:"管理控制台"})]})]})}),e(zn,{className:"flex-1",scrollbars:"vertical",children:e(ne,{p:"3",children:e(C,{direction:"column",gap:"2",children:o.map(c=>{const h=i===c.key;return r(_r,{to:c.href,onClick:()=>n(Mr(c.key)),className:de("menu-item",h&&"active"),children:[e("div",{className:"icon",children:c.icon}),t&&e("div",{className:"text",children:e("div",{className:"title",children:c.title})}),h&&t&&e("div",{className:"indicator"})]},c.key)})})})}),e(C,{p:"3",className:"border-t border-gray-200/50 dark:border-gray-700/50 flex-shrink-0",children:r(C,{align:"center",gap:"2",p:"2",className:de("rounded-xl bg-gray-50/50 dark:bg-gray-800/50 transition-all duration-200 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700",!t&&"justify-center"),children:[r(re.Root,{className:"w-8 h-8 min-w-8 border-2 border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e(re.Image,{src:"https://i.pravatar.cc/150?u=admin",alt:"管理员"}),e(re.Fallback,{children:"管"})]}),t&&r(C,{direction:"column",gap:"0",className:"flex-1 min-w-0",children:[e(J,{size:"2",weight:"medium",className:"truncate text-gray-900 dark:text-gray-100",children:"管理员"}),e(J,{size:"1",color:"gray",className:"truncate",children:"admin@zhin.com"})]})]})})]}),r(C,{direction:"column",className:"flex-1 overflow-hidden",children:[e(ne,{className:"glass border-b border-gray-200/50 dark:border-gray-700/50 shadow-sm",children:r(C,{justify:"between",align:"center",px:"4",className:"h-16",children:[r(C,{align:"center",gap:"3",children:[e(_e,{variant:"ghost",size:"2",onClick:()=>n(Dr()),className:"hover-lift rounded-xl",children:e(dr,{className:"w-5 h-5"})}),r(C,{direction:"column",gap:"0",children:[e(Ae,{size:"3",className:"text-gray-900 dark:text-gray-100",children:"控制台"}),e(J,{size:"1",color:"gray",children:"欢迎回来!"})]})]}),e(C,{className:"hidden md:flex flex-1 max-w-xl mx-6",children:r(ne,{className:"relative",children:[e(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500"}),e(wn.Root,{placeholder:"搜索功能、用户、设置...",size:"2",className:"w-full pl-10"})]})}),r(C,{align:"center",gap:"2",children:[e(yn,{}),r(ne,{className:"relative",children:[e(_e,{variant:"ghost",size:"2",className:"hover-lift rounded-xl",children:e(ur,{className:"w-5 h-5"})}),e(vn,{color:"red",variant:"solid",size:"1",className:"absolute -top-1 -right-1 min-w-5 h-5 flex items-center justify-center p-0",children:"3"})]}),r(W.Root,{children:[e(W.Trigger,{asChild:!0,children:r(C,{align:"center",gap:"2",px:"2",py:"1",className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 transition-all duration-200 rounded-xl",children:[r(re.Root,{className:"w-8 h-8 border-2 border-blue-500/20 dark:border-blue-400/30",children:[e(re.Image,{src:"https://i.pravatar.cc/150?u=admin",alt:"管理员"}),e(re.Fallback,{children:"管"})]}),r(C,{direction:"column",gap:"0",className:"hidden lg:flex",children:[e(J,{size:"2",weight:"medium",className:"text-gray-900 dark:text-gray-100",children:"管理员"}),e(J,{size:"1",color:"gray",children:"admin@zhin.com"})]})]})}),r(W.Content,{align:"end",className:"min-w-56",children:[r(ne,{p:"3",className:"border-b border-gray-200 dark:border-gray-700",children:[e(J,{size:"2",weight:"bold",className:"block",children:"登录为"}),e(J,{size:"1",color:"gray",className:"block",children:"admin@zhin.com"})]}),r(W.Item,{children:[e(gr,{className:"mr-2 h-4 w-4"}),"我的设置"]}),r(W.Item,{children:[e(mr,{className:"mr-2 h-4 w-4"}),"团队设置"]}),r(W.Item,{children:[e(pr,{className:"mr-2 h-4 w-4"}),"数据分析"]}),r(W.Item,{children:[e(br,{className:"mr-2 h-4 w-4"}),"帮助与反馈"]}),e(W.Separator,{}),r(W.Item,{color:"red",children:[e(fr,{className:"mr-2 h-4 w-4"}),"退出登录"]})]})]})]})]})}),e(C,{className:"flex-1 overflow-auto",children:e(xn,{size:"4",p:"6",children:e(Vr,{})})})]})]})}function kn(){const n=Fe(),[t,i]=z(null),[a,o]=z(null),[c,h]=z(!0),[g,d]=z(null);q(()=>{u();const f=setInterval(u,5e3);return()=>clearInterval(f)},[]);const u=async()=>{try{const[f,R]=await Promise.all([fetch("/api/stats",{credentials:"include"}),fetch("/api/system/status",{credentials:"include"})]);if(!f.ok||!R.ok)throw new Error("API 请求失败");const N=await f.json(),k=await R.json();N.success&&k.success&&(i(N.data),o(k.data),d(null))}catch(f){d(f.message)}finally{h(!1)}},b=f=>{const R=Math.floor(f/86400),N=Math.floor(f%86400/3600),k=Math.floor(f%3600/60);return`${R}天 ${N}小时 ${k}分钟`},w=f=>`${(f/1024/1024).toFixed(2)} MB`;return c?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):g?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",g]})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"6",children:[e(_,{size:"8",children:"系统概览"}),e(s,{color:"gray",children:"实时监控您的机器人框架运行状态"})]}),r(oe,{columns:{initial:"1",sm:"2",lg:"4"},gap:"4",mb:"6",children:[e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"插件总数"}),e(I,{p:"2",style:{borderRadius:"8px",backgroundColor:"var(--purple-3)"},children:e(K,{size:16,color:"var(--purple-9)"})})]}),e(_,{size:"7",children:t?.plugins.total||0}),r(l,{align:"center",gap:"1",children:[e(j,{color:"blue",children:t?.plugins.active||0}),e(s,{size:"1",color:"gray",children:"个活跃"})]})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"机器人"}),e(ce,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.bots.total||0}),r(s,{size:"1",color:"green",children:[t?.bots.online||0," 个在线"]})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"命令数量"}),e(ke,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.commands||0}),e(s,{size:"1",color:"gray",children:"可用命令"})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"组件数量"}),e(yr,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.components||0}),e(s,{size:"1",color:"gray",children:"已注册组件"})]})})]}),r(oe,{columns:{initial:"1",md:"2"},gap:"4",mb:"6",children:[e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"系统信息"}),e(s,{size:"2",color:"gray",children:"服务器运行状态"})]}),r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(Ce,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"运行时间"})]}),e(j,{variant:"soft",children:a?b(a.uptime):"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(vr,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"平台"})]}),e(j,{variant:"soft",children:a?.platform||"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ke,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"Node 版本"})]}),e(j,{variant:"soft",children:a?.nodeVersion||"-"})]})]})]})}),e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"资源使用"}),e(s,{size:"2",color:"gray",children:"内存使用情况"})]}),r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"堆内存使用"})]}),e(j,{variant:"soft",children:t?`${t.memory.toFixed(2)} MB`:"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"总堆内存"})]}),e(j,{variant:"soft",children:a?w(a.memory.heapTotal):"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"RSS"})]}),e(j,{variant:"soft",children:a?w(a.memory.rss):"-"})]})]})]})})]}),e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"快速操作"}),e(s,{size:"2",color:"gray",children:"常用功能快捷入口"})]}),r(oe,{columns:{initial:"1",md:"3"},gap:"3",children:[e(U,{variant:"outline",onClick:()=>n("/plugins"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(K,{size:20,color:"var(--blue-9)"}),e(s,{weight:"medium",children:"插件管理"}),e(s,{size:"1",color:"gray",children:"查看和管理插件"})]})}),e(U,{variant:"outline",onClick:()=>n("/bots"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(ce,{size:20,color:"var(--green-9)"}),e(s,{weight:"medium",children:"机器人状态"}),e(s,{size:"1",color:"gray",children:"监控机器人运行"})]})}),e(U,{variant:"outline",onClick:()=>n("/logs"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(se,{size:20,color:"var(--purple-9)"}),e(s,{weight:"medium",children:"系统日志"}),e(s,{size:"1",color:"gray",children:"查看运行日志"})]})})]})]})})]})}const{Flex:O,Box:Cn,Spinner:Sn,Text:L,Callout:ze,Heading:xe,Badge:Me,Grid:De,Card:Ve,Separator:jn}=Te;function Rn(){const n=Fe(),[t,i]=z([]),[a,o]=z(!0),[c,h]=z(null);q(()=>{g();const d=setInterval(g,1e4);return()=>clearInterval(d)},[]);const g=async()=>{try{const d=await fetch("/api/plugins",{credentials:"include"});if(!d.ok)throw new Error("API 请求失败");const u=await d.json();if(u.success)i(u.data),h(null);else throw new Error("数据格式错误")}catch(d){h(d.message)}finally{o(!1)}};return a?e(O,{align:"center",justify:"center",className:"h-full",children:r(O,{direction:"column",align:"center",gap:"3",children:[e(Sn,{size:"3"}),e(L,{size:"2",color:"gray",children:"加载中..."})]})}):c?e(O,{align:"center",justify:"center",className:"h-full",children:r(ze.Root,{color:"red",children:[e(ze.Icon,{children:e(te,{})}),r(ze.Text,{children:["加载失败: ",c]})]})}):r(Cn,{children:[r(O,{direction:"column",gap:"2",mb:"4",children:[e(xe,{size:"6",children:"插件管理"}),r(O,{align:"center",gap:"2",children:[r(L,{size:"2",color:"gray",children:["共 ",t.length," 个插件"]}),e(Me,{color:"green",size:"1",children:t.filter(d=>d.status==="active").length}),e(L,{size:"2",color:"gray",children:"个运行中"})]})]}),e(De,{columns:{initial:"1",sm:"2",lg:"3"},gap:"3",children:t.map((d,u)=>e(Ve,{className:"cursor-pointer hover-lift transition-smooth",onClick:()=>n(`/plugins/${encodeURIComponent(d.name)}`),children:r(O,{direction:"column",gap:"2",p:"2",children:[r(O,{justify:"between",align:"center",children:[r(O,{align:"center",gap:"2",children:[e(O,{align:"center",justify:"center",className:"w-8 h-8 rounded-lg bg-blue-500/10 dark:bg-blue-400/10",children:e(K,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e(xe,{size:"3",children:d.name})]}),e(Me,{color:d.status==="active"?"green":"gray",size:"1",children:d.status==="active"?"运行中":"已停止"})]}),e(L,{size:"1",color:"gray",className:"line-clamp-2",children:d.description||"暂无描述"}),e(jn,{size:"4",my:"1"}),r(De,{columns:{initial:"1",sm:"2",lg:"4"},gap:"1",children:[r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-blue-500/5 dark:bg-blue-400/5 p-1.5",children:[e(Se,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.commandCount}),e(L,{size:"1",color:"gray",children:"命令"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-green-500/5 dark:bg-green-400/5 p-1.5",children:[e(Je,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.componentCount}),e(L,{size:"1",color:"gray",children:"组件"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-purple-500/5 dark:bg-purple-400/5 p-1.5",children:[e(pe,{className:"w-3 h-3 text-purple-600 dark:text-purple-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.middlewareCount}),e(L,{size:"1",color:"gray",children:"中间件"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-orange-500/5 dark:bg-orange-400/5 p-1.5",children:[e(je,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.contextCount}),e(L,{size:"1",color:"gray",children:"上下文"})]})]})]})},`${d.name}-${u}`))}),t.length===0&&e(Ve,{className:"mt-6",children:r(O,{direction:"column",align:"center",gap:"3",py:"8",children:[e(O,{align:"center",justify:"center",className:"w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-800",children:e(K,{className:"w-8 h-8 text-gray-400"})}),r(O,{direction:"column",align:"center",gap:"1",children:[e(xe,{size:"4",children:"暂无插件"}),e(L,{size:"2",color:"gray",children:"请先安装并启用插件"})]})]})})]})}function In({field:n,value:t,onChange:i}){return n.enum?r(T.Root,{size:"2",value:t?.toString()||"",onValueChange:i,children:[e(T.Trigger,{className:"w-full hover:border-blue-500 dark:hover:border-blue-400 transition-colors"}),e(T.Content,{className:"shadow-lg",children:n.enum.map(a=>e(T.Item,{value:a.toString(),className:"hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",children:a.toString()},a))})]}):n.description?.includes("多行")||n.key?.includes("description")?e(Q,{size:"2",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入",rows:3,className:"font-sans resize-y hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus:ring-2 focus:ring-blue-500/20"}):e(E.Root,{size:"2",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"})}function $n({field:n,value:t,onChange:i}){return e(E.Root,{size:"2",type:"number",value:t?.toString()||"",onChange:a=>i(parseFloat(a.target.value)||0),placeholder:n.description||"请输入数字",min:n.min,max:n.max,className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"})}function On({value:n,onChange:t}){return r(l,{align:"center",gap:"3",className:"p-3 rounded-lg bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-800",children:[e(qe,{size:"2",checked:n===!0,onCheckedChange:t,className:"cursor-pointer"}),r(l,{direction:"column",gap:"1",children:[e(s,{size:"2",weight:"bold",color:n?"green":"gray",children:n?"已启用":"已禁用"}),e(s,{size:"1",color:"gray",children:n?"功能当前处于开启状态":"功能当前处于关闭状态"})]})]})}function Tn({field:n,value:t,onChange:i}){const a=typeof t=="number"?t:n.default||0;return e("div",{className:"p-4 rounded-lg bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 border border-blue-200 dark:border-blue-800",children:r(l,{direction:"column",gap:"3",children:[r(l,{align:"center",gap:"3",children:[e("input",{type:"range",min:n.min||0,max:n.max||1,step:n.step||.01,value:a,onChange:o=>i(parseFloat(o.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-blue-200 dark:bg-blue-800 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-blue-600 dark:[&::-webkit-slider-thumb]:bg-blue-400 [&::-webkit-slider-thumb]:cursor-pointer hover:[&::-webkit-slider-thumb]:bg-blue-700 dark:hover:[&::-webkit-slider-thumb]:bg-blue-300 transition-all"}),e(E.Root,{size:"2",type:"number",value:(a*100).toFixed(0),onChange:o=>i(parseFloat(o.target.value)/100),min:(n.min||0)*100,max:(n.max||1)*100,className:"w-24",children:e(E.Slot,{side:"right",children:e(s,{size:"1",weight:"bold",className:"text-blue-600 dark:text-blue-400",children:"%"})})})]}),r(l,{align:"center",justify:"between",children:[e(s,{size:"1",color:"gray",children:"当前值"}),r(j,{color:"blue",size:"2",variant:"soft",className:"font-mono",children:[(a*100).toFixed(1),"%"]})]})]})})}function Fn({field:n,value:t,onChange:i}){const a=t instanceof Date?t.toISOString().split("T")[0]:t||"";return e("div",{className:"relative",children:e(E.Root,{size:"2",type:"date",value:a,onChange:o=>i(new Date(o.target.value)),placeholder:n.description||"选择日期",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20",children:e(E.Slot,{side:"left",children:e(zr,{className:"w-4 h-4 text-gray-500"})})})})}function Ln({field:n,value:t,onChange:i}){const a=t instanceof RegExp?t.source:typeof t=="string"?t:"";return e("div",{className:"p-3 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800",children:r(l,{direction:"column",gap:"2",children:[r(E.Root,{size:"2",value:a,onChange:o=>{try{i(new RegExp(o.target.value))}catch{i(o.target.value)}},placeholder:n.description||"请输入正则表达式",className:"font-mono text-sm hover:border-amber-500 dark:hover:border-amber-400 transition-colors",children:[e(E.Slot,{side:"left",children:e(s,{size:"1",className:"text-amber-600 dark:text-amber-400 font-bold",children:"/"})}),e(E.Slot,{side:"right",children:e(s,{size:"1",className:"text-amber-600 dark:text-amber-400 font-bold",children:"/"})})]}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-amber-600 dark:text-amber-400"}),e(s,{size:"1",className:"text-amber-700 dark:text-amber-300",children:"输入正则表达式模式 (省略斜杠)"})]})]})})}function Pn({field:n,value:t}){const i=n.default||t;return e("div",{className:"p-3 rounded-lg bg-gray-100 dark:bg-gray-900 border border-gray-300 dark:border-gray-700",children:r(l,{align:"center",gap:"3",children:[e(wr,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),e(j,{variant:"soft",size:"2",className:"font-mono",children:String(i)}),e(s,{size:"1",color:"gray",className:"ml-auto",children:"(常量,不可修改)"})]})})}function En({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800",children:r(l,{direction:"column",gap:"3",children:[r(l,{align:"center",gap:"2",children:[e(He,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(s,{size:"1",weight:"bold",className:"text-purple-700 dark:text-purple-300",children:"JSON 格式输入"})]}),e(Q,{size:"2",value:typeof t=="object"?JSON.stringify(t,null,2):String(t||""),onChange:a=>{try{i(JSON.parse(a.target.value))}catch{i(a.target.value)}},placeholder:n.description||"支持任意类型 (JSON 格式)",rows:4,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-purple-500 dark:hover:border-purple-400 transition-colors"}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-purple-600 dark:text-purple-400"}),e(s,{size:"1",className:"text-purple-700 dark:text-purple-300",children:"支持: 字符串、数字、布尔值、对象、数组"})]})]})})}function Bn({fieldName:n,field:t,value:i,onChange:a,onArrayItemChange:o,renderNestedField:c}){const h=Array.isArray(i)?i:[],g=t.inner||t.items;return g&&["string","number"].includes(g.type)?e("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"2",children:[e(Ge,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(s,{size:"1",weight:"bold",className:"text-green-700 dark:text-green-300",children:"列表输入 (每行一个值)"})]}),e(Q,{size:"2",value:h.join(`
|
|
10
|
+
`),onChange:d=>{const u=d.target.value.split(`
|
|
11
|
+
`).filter(Boolean),b=g.type==="number"?u.map(w=>parseFloat(w)||0):u;a(b)},placeholder:`每行一个值
|
|
12
|
+
${t.description||""}`,rows:4,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-green-500 dark:hover:border-green-400 transition-colors"})]})}):r(l,{direction:"column",gap:"2",children:[e("div",{className:"space-y-2",children:h.map((d,u)=>e(S,{size:"1",variant:"surface",className:"border border-gray-200 dark:border-gray-800 hover:border-blue-300 dark:hover:border-blue-700 transition-colors group",children:r(l,{direction:"column",gap:"2",className:"p-3",children:[r(l,{justify:"between",align:"center",children:[e(l,{align:"center",gap:"2",children:e(j,{size:"1",variant:"soft",color:"blue",className:"font-mono",children:u+1})}),e(U,{size:"1",variant:"ghost",color:"red",onClick:()=>{const b=h.filter((w,f)=>f!==u);a(b)},className:"opacity-0 group-hover:opacity-100 transition-opacity",children:e(Re,{className:"w-3 h-3"})})]}),e("div",{className:"pl-2 border-l-2 border-blue-200 dark:border-blue-800",children:g&&c(`${n}[${u}]`,g,d,b=>{o?.(n,u,b)})})]})},u))}),r(U,{size:"2",variant:"soft",onClick:()=>{const d=g?.default||(g?.type==="object"?{}:"");a([...h,d])},className:"w-full hover:bg-blue-100 dark:hover:bg-blue-900/30 border-2 border-dashed border-blue-300 dark:border-blue-700 hover:border-blue-500 dark:hover:border-blue-500 transition-colors",children:[e(xr,{className:"w-4 h-4"}),"添加项"]})]})}function An({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-cyan-50 dark:bg-cyan-900/20 border border-cyan-200 dark:border-cyan-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"2",children:[e(Ge,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(s,{size:"1",weight:"bold",className:"text-cyan-700 dark:text-cyan-300",children:"数组输入 (每行一个值)"})]}),e(Q,{size:"2",value:Array.isArray(t)?t.join(`
|
|
13
13
|
`):"",onChange:a=>i(a.target.value.split(`
|
|
14
14
|
`).filter(Boolean)),placeholder:`每行一个值
|
|
15
|
-
${n.description||""}`,rows:3,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-cyan-500 dark:hover:border-cyan-400 transition-colors"})]})})}function _n({fieldName:n,field:t,value:i,onArrayItemChange:a,renderNestedField:o}){const c=Array.isArray(i)?i:[],h=t.list||[];return e("div",{className:"space-y-3",children:h.map((u,d)=>e("div",{className:"p-3 rounded-lg bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-200 dark:border-indigo-800 hover:border-indigo-300 dark:hover:border-indigo-700 transition-colors",children:r(l,{direction:"column",gap:"2",children:[e(l,{align:"center",gap:"2",children:r(j,{size:"1",variant:"soft",color:"indigo",className:"font-mono",children:["#",d+1]})}),u.description&&e(s,{size:"1",className:"text-indigo-700 dark:text-indigo-300",children:u.description}),e("div",{className:"mt-1",children:o(`${n}[${d}]`,u,c[d],g=>{a?.(n,d,g)})})]})},d))})}function Mn({fieldName:n,field:t,value:i,renderField:a}){const o=t.dict||t.properties||{};return r("div",{className:"rounded-lg border-2 border-blue-200 dark:border-blue-800 bg-gradient-to-br from-blue-50/50 to-cyan-50/50 dark:from-blue-900/10 dark:to-cyan-900/10 overflow-hidden",children:[e("div",{className:"px-4 py-2 bg-blue-100 dark:bg-blue-900/30 border-b border-blue-200 dark:border-blue-800",children:e(l,{align:"center",gap:"2",children:e(Z,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})})}),e("div",{className:"p-4 space-y-3",children:Object.entries(o).map(([c,h],u)=>r("div",{children:[e("div",{className:"p-3 rounded-md bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"1",children:[e(s,{size:"2",weight:"bold",className:"text-gray-900 dark:text-gray-100",children:h.key||c}),h.required&&e(s,{size:"2",weight:"bold",color:"red",className:"leading-none",children:"*"})]}),h.description&&e(s,{size:"1",color:"gray",children:h.description}),e("div",{className:"mt-1",children:a(c,h,n)})]})}),u<Object.entries(o).length-1&&e(Ie,{size:"4",className:"my-2"})]},c))})]})}function Dn({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-violet-50 dark:bg-violet-900/20 border border-violet-200 dark:border-violet-800",children:r(l,{direction:"column",gap:"3",children:[e(l,{align:"center",gap:"2",children:e(He,{className:"w-4 h-4 text-violet-600 dark:text-violet-400"})}),e(Y,{size:"2",value:typeof t=="object"?JSON.stringify(t,null,2):t||"{}",onChange:a=>{try{const o=JSON.parse(a.target.value);i(o)}catch{}},placeholder:n.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-violet-500 dark:hover:border-violet-400 transition-colors"}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-violet-600 dark:text-violet-400"}),e(s,{size:"1",className:"text-violet-700 dark:text-violet-300",children:'键值对格式: {"key": "value"}'})]})]})})}function Vn({field:n,value:t,onChange:i}){const a=n.list||[];if(a.length===0)return e(E.Root,{size:"2",value:t||"",onChange:c=>i(c.target.value),placeholder:n.description||"请输入值",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"});const o=a.map(c=>c.default||c.type);return e("div",{className:"p-3 rounded-lg bg-gradient-to-br from-pink-50 to-rose-50 dark:from-pink-900/20 dark:to-rose-900/20 border border-pink-200 dark:border-pink-800",children:r(l,{direction:"column",gap:"2",children:[e(l,{align:"center",gap:"2",children:e(Nr,{className:"w-4 h-4 text-pink-600 dark:text-pink-400"})}),r(T.Root,{size:"2",value:t?.toString()||"",onValueChange:i,children:[e(T.Trigger,{className:"w-full hover:border-pink-500 dark:hover:border-pink-400 transition-colors"}),e(T.Content,{className:"shadow-lg",children:o.map((c,h)=>e(T.Item,{value:String(c),className:"hover:bg-pink-50 dark:hover:bg-pink-900/20 transition-colors",children:e(l,{align:"center",gap:"2",children:e(s,{children:String(c)})})},h))})]})]})})}function Un({fieldName:n,field:t,value:i,onChange:a,renderNestedField:o}){const c=t.list||[];return r("div",{className:"rounded-lg border-2 border-teal-200 dark:border-teal-800 bg-gradient-to-br from-teal-50/50 to-emerald-50/50 dark:from-teal-900/10 dark:to-emerald-900/10 overflow-hidden",children:[e("div",{className:"px-4 py-2 bg-teal-100 dark:bg-teal-900/30 border-b border-teal-200 dark:border-teal-800",children:e(l,{align:"center",gap:"2",children:e(pe,{className:"w-4 h-4 text-teal-600 dark:text-teal-400"})})}),e("div",{className:"p-4 space-y-3",children:c.map((h,u)=>e("div",{className:"p-3 rounded-md bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[h.description&&e(s,{size:"1",color:"gray",children:h.description}),e("div",{className:"mt-1",children:o(`${n}[${u}]`,h,i,a)})]})},u))})]})}function Wn(n){const{field:t}=n;switch(t.type){case"string":return e(In,{...n});case"number":case"integer":return e($n,{...n});case"boolean":return e(On,{...n});case"percent":return e(Tn,{...n});case"date":return e(Fn,{...n});case"regexp":return e(Ln,{...n});case"const":return e(Pn,{...n});case"any":return e(En,{...n});case"list":return e(Bn,{...n});case"array":return e(An,{...n});case"tuple":return e(_n,{...n});case"object":return e(Mn,{...n});case"dict":return e(Dn,{...n});case"union":return e(Vn,{...n});case"intersect":return e(Un,{...n});default:return e(Y,{size:"1",value:typeof n.value=="object"?JSON.stringify(n.value,null,2):n.value||"",onChange:i=>{try{const a=JSON.parse(i.target.value);n.onChange(a)}catch{n.onChange(i.target.value)}},placeholder:t.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function Xe({field:n,value:t,onChange:i}){switch(n.type){case"string":return e(E.Root,{size:"1",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入"});case"number":case"integer":return e(E.Root,{size:"1",type:"number",value:t?.toString()||"",onChange:a=>i(parseFloat(a.target.value)||0),placeholder:n.description||"请输入数字",min:n.min,max:n.max});case"boolean":return r(l,{align:"center",gap:"2",children:[e(qe,{checked:t===!0,onCheckedChange:i}),e(s,{size:"2",color:t?"green":"gray",children:t?"已启用":"已禁用"})]});case"object":{const a=n.dict||n.properties||{};return e(S,{size:"1",children:e(l,{direction:"column",gap:"2",p:"2",children:Object.entries(a).map(([o,c])=>r(I,{children:[e(s,{size:"1",weight:"bold",children:o}),e(Xe,{fieldName:o,field:c,value:t?.[o],onChange:h=>{i({...t,[o]:h})}})]},o))})})}default:return e(Y,{size:"1",value:typeof t=="object"?JSON.stringify(t,null,2):t||"",onChange:a=>{try{i(JSON.parse(a.target.value))}catch{i(a.target.value)}},rows:3,className:"font-mono text-xs"})}}function Jn({pluginName:n,onSuccess:t}){const[i,a]=w({}),[o,c]=w(null),[h,u]=w(void 0),{config:d,schema:g,loading:b,error:z,connected:v,setConfig:R}=Ur(n);q(()=>{d&&a(d)},[d]);const x=async()=>{if(!v){c(null);return}try{await R(i),c("配置已保存成功"),setTimeout(()=>{u(void 0),t?.(),c(null)},1500)}catch(m){console.error("保存配置失败:",m)}},N=(m,f)=>{a(y=>({...y,[m]:f}))},B=(m,f,y)=>{a($=>({...$,[m]:{...$[m]||{},[f]:y}}))},M=(m,f,y)=>{a($=>{const Q=Array.isArray($[m])?[...$[m]]:[];return Q[f]=y,{...$,[m]:Q}})},D=(m,f,y)=>{const $=y?i[y]?.[m]??f.default:i[m]??f.default;return e(Wn,{fieldName:m,field:f,value:$,onChange:y?ie=>B(y,m,ie):ie=>N(m,ie),parentPath:y,onNestedChange:B,onArrayItemChange:M,renderField:D,renderNestedField:(ie,Qe,er,rr)=>e(Xe,{fieldName:ie,field:Qe,value:er,onChange:rr})})},A=g?.properties||g?.dict||{};return!g||!A||Object.keys(A).length===0?null:e(S,{size:"2",className:"mt-4",children:e(ae.Root,{type:"single",collapsible:!0,value:h,onValueChange:u,children:r(ae.Item,{value:"config",className:"border-none",children:[e(ae.Header,{children:e(ae.Trigger,{className:"w-full group",children:r(l,{justify:"between",align:"center",className:"w-full p-3 hover:bg-gray-50 dark:hover:bg-gray-900/50 rounded-lg transition-colors",children:[r(l,{align:"center",gap:"2",children:[e(kr,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e(s,{size:"3",weight:"bold",children:"插件配置"}),r(j,{size:"1",color:"gray",variant:"soft",children:[Object.keys(A).length," 项"]})]}),e(Cr,{className:"w-5 h-5 text-gray-500 transition-transform duration-200 group-data-[state=open]:rotate-180"})]})})}),e(ae.Content,{className:"overflow-hidden data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up",children:r(I,{className:"pt-2 pb-4",children:[o&&e("div",{className:"mb-3 animate-in fade-in slide-in-from-top-2 duration-300",children:r(F.Root,{color:"green",size:"1",className:"shadow-sm",children:[e(F.Icon,{children:e(Sr,{})}),e(F.Text,{className:"font-medium",children:o})]})}),z&&e("div",{className:"mb-3 animate-in fade-in slide-in-from-top-2 duration-300",children:r(F.Root,{color:"red",size:"1",className:"shadow-sm",children:[e(F.Icon,{children:e(te,{})}),e(F.Text,{className:"font-medium",children:z})]})}),e(l,{direction:"column",gap:"3",children:Object.entries(A).map(([m,f])=>{const y=f;return e("div",{className:"group p-3 rounded-lg bg-gray-50 dark:bg-gray-900/50 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"1",children:[e(s,{size:"2",weight:"bold",className:"text-gray-900 dark:text-gray-100",children:y.key||m}),y.required&&e(s,{size:"2",weight:"bold",color:"red",className:"leading-none",children:"*"})]}),y.description&&e(s,{size:"1",color:"gray",className:"leading-relaxed",children:y.description}),e("div",{className:"mt-1",children:D(y.key||m,y)})]})},m)})}),r(l,{gap:"2",justify:"end",className:"mt-4 pt-3 border-t border-gray-200 dark:border-gray-800",children:[r(U,{size:"2",variant:"soft",onClick:()=>u(void 0),disabled:b,className:"hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors",children:[e(jr,{className:"w-4 h-4"}),"取消"]}),e(U,{size:"2",onClick:x,disabled:b,className:"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white transition-colors shadow-sm",children:b?r(me,{children:[e(fe,{}),e("span",{children:"保存中..."})]}):r(me,{children:[e(Rr,{className:"w-4 h-4"}),e("span",{children:"保存配置"})]})})]})]})})]})})})}const{Flex:p,Box:H,Spinner:Hn,Text:C,Callout:Ne,Heading:K,Badge:V,Grid:Ue,Card:P,Button:We,Code:ne,Separator:X}=Te;function Gn(){const{name:n}=Kr(),t=Fe(),[i,a]=w(null),[o,c]=w(!0),[h,u]=w(null);q(()=>{n&&d(n)},[n]);const d=async g=>{try{const b=await fetch(`/api/plugins/${encodeURIComponent(g)}`,{credentials:"include"});if(!b.ok)throw new Error("API 请求失败");const z=await b.json();if(z.success)a(z.data),u(null);else throw new Error("数据格式错误")}catch(b){u(b.message)}finally{c(!1)}};return o?e(p,{align:"center",justify:"center",className:"h-full",children:r(p,{direction:"column",align:"center",gap:"3",children:[e(Hn,{size:"3"}),e(C,{size:"2",color:"gray",children:"加载中..."})]})}):h||!i?r(H,{children:[r(We,{variant:"ghost",onClick:()=>t("/plugins"),mb:"4",size:"2",children:[e(Le,{className:"w-4 h-4"}),"返回"]}),r(Ne.Root,{color:"red",children:[e(Ne.Icon,{children:e(te,{})}),r(Ne.Text,{children:["加载失败: ",h||"插件不存在"]})]})]}):r(H,{children:[r(p,{direction:"column",gap:"3",mb:"4",children:[r(We,{variant:"ghost",onClick:()=>t("/plugins"),size:"2",children:[e(Le,{className:"w-4 h-4"}),"返回"]}),r(p,{align:"center",gap:"3",children:[e(p,{align:"center",justify:"center",className:"w-12 h-12 rounded-xl bg-blue-500/10 dark:bg-blue-400/10",children:e(Z,{className:"w-6 h-6 text-blue-600 dark:text-blue-400"})}),r(p,{direction:"column",gap:"1",children:[r(p,{align:"center",gap:"2",children:[e(K,{size:"5",children:i.name}),e(V,{color:i.status==="active"?"green":"gray",size:"1",children:i.status==="active"?"运行中":"已停止"})]}),e(C,{size:"2",color:"gray",children:i.description||"暂无描述"})]})]})]}),e(Jn,{pluginName:i.name,onSuccess:()=>{}}),e(X,{size:"4",my:"4"}),r(Ue,{columns:{initial:"2",sm:"3",md:"6"},gap:"2",mb:"4",children:[e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Se,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e(C,{size:"4",weight:"bold",children:i.statistics.commandCount}),e(C,{size:"1",color:"gray",children:"命令"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Je,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(C,{size:"4",weight:"bold",children:i.statistics.componentCount}),e(C,{size:"1",color:"gray",children:"组件"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(pe,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(C,{size:"4",weight:"bold",children:i.statistics.middlewareCount}),e(C,{size:"1",color:"gray",children:"中间件"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(je,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"}),e(C,{size:"4",weight:"bold",children:i.statistics.contextCount}),e(C,{size:"1",color:"gray",children:"上下文"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Ce,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e(C,{size:"4",weight:"bold",children:i.statistics.cronCount}),e(C,{size:"1",color:"gray",children:"定时任务"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(se,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(C,{size:"4",weight:"bold",children:i.statistics.definitionCount}),e(C,{size:"1",color:"gray",children:"数据模型"})]})})]}),r(Ue,{columns:{initial:"1",md:"2"},gap:"3",children:[i.commands.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(Se,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e(K,{size:"3",children:"命令"}),e(V,{size:"1",children:i.commands.length})]}),e(X,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.commands.map((g,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:e(p,{direction:"column",gap:"1",children:e(p,{align:"center",gap:"2",children:e(ne,{size:"2",children:g.name})})})},b))})]})}),i.components.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(H,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(K,{size:"3",children:"组件"}),e(V,{size:"1",children:i.components.length})]}),e(X,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.components.map((g,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[r(p,{align:"center",gap:"2",children:[e(ne,{size:"2",children:g.name}),e(V,{size:"1",variant:"soft",children:g.type})]}),r(C,{size:"1",color:"gray",children:["属性数: ",Object.keys(g.props).length]})]})},b))})]})}),i.middlewares.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(pe,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(K,{size:"3",children:"中间件"}),e(V,{size:"1",children:i.middlewares.length})]}),e(X,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.middlewares.map((g,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{align:"center",gap:"2",children:[e(ne,{size:"2",children:g.id}),e(V,{size:"1",variant:"soft",children:g.type})]})},b))})]})}),i.contexts.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(je,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"}),e(K,{size:"3",children:"上下文"}),e(V,{size:"1",children:i.contexts.length})]}),e(X,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.contexts.map((g,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[e(ne,{size:"2",children:g.name}),e(C,{size:"1",color:"gray",children:g.description})]})},b))})]})}),i.crons.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(Ce,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e(K,{size:"3",children:"定时任务"}),e(V,{size:"1",children:i.crons.length})]}),e(X,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.crons.map((g,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{justify:"between",align:"center",children:[r(p,{direction:"column",gap:"1",children:[e(ne,{size:"2",children:g.id}),e(C,{size:"1",color:"gray",children:g.pattern})]}),e(V,{color:g.running?"green":"gray",size:"1",children:g.running?"运行中":"已停止"})]})},b))})]})}),i.definitions.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(se,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(K,{size:"3",children:"数据模型"}),e(V,{size:"1",children:i.definitions.length})]}),e(X,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.definitions.map((g,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[e(ne,{size:"2",children:g.name}),r(C,{size:"1",color:"gray",children:["字段: ",g.fields.join(", ")]})]})},b))})]})})]})]})}function qn(){const[n,t]=w([]),[i,a]=w(!0),[o,c]=w(null);q(()=>{h();const u=setInterval(h,5e3);return()=>clearInterval(u)},[]);const h=async()=>{try{const u=await fetch("/api/bots",{credentials:"include"});if(!u.ok)throw new Error("API 请求失败");const d=await u.json();if(d.success)t(d.data),c(null);else throw new Error("数据格式错误")}catch(u){c(u.message)}finally{a(!1)}};return i?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):o?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",o]})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"6",children:[e(_,{size:"8",children:"机器人管理"}),r(l,{align:"center",gap:"2",children:[r(s,{color:"gray",children:["共 ",n.length," 个机器人,"]}),e(j,{color:"green",children:n.filter(u=>u.connected).length}),e(s,{color:"gray",children:"个在线"})]})]}),e(Ie,{size:"4",mb:"6"}),e(oe,{columns:{initial:"1",sm:"2",lg:"3"},gap:"4",children:n.map((u,d)=>e(S,{children:r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(I,{style:{padding:"8px",borderRadius:"8px",backgroundColor:u.connected?"var(--green-3)":"var(--gray-3)"},children:e(ce,{size:20,color:u.connected?"var(--green-9)":"var(--gray-9)"})}),e(s,{size:"4",weight:"bold",children:u.name})]}),r(I,{style:{position:"relative"},children:[e(j,{color:u.connected?"green":"gray",children:e(l,{align:"center",gap:"1",children:u.connected?r(me,{children:[e(Ir,{size:12}),"在线"]}):r(me,{children:[e($r,{size:12}),"离线"]})})}),u.connected&&e(I,{style:{position:"absolute",top:"-4px",right:"-4px",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"var(--green-9)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})]})]}),r(l,{align:"center",gap:"2",children:[e(s,{size:"2",color:"gray",children:"适配器:"}),e(j,{variant:"outline",children:u.adapter})]}),e(Ie,{size:"4"}),r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(ke,{size:16,color:u.status==="online"?"var(--green-9)":"var(--gray-9)"}),e(s,{size:"2",color:"gray",children:"运行状态"})]}),e(j,{color:u.status==="online"?"green":"gray",children:u.status==="online"?"运行中":"已停止"})]}),r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(Z,{size:16,color:"var(--blue-9)"}),e(s,{size:"2",color:"gray",children:"适配器类型"})]}),e(s,{size:"2",weight:"medium",children:u.adapter})]}),r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(Or,{size:16,color:"var(--purple-9)"}),e(s,{size:"2",color:"gray",children:"连接状态"})]}),e(s,{size:"2",weight:"medium",color:u.connected?"green":"gray",children:u.connected?"已连接":"未连接"})]})]})]})},`${u.adapter}-${u.name}-${d}`))}),n.length===0&&e(S,{children:r(l,{direction:"column",align:"center",gap:"4",py:"9",children:[e(ce,{size:64,color:"var(--gray-6)"}),r(l,{direction:"column",align:"center",gap:"2",children:[e(_,{size:"4",children:"暂无机器人"}),e(s,{color:"gray",children:"请先配置并启动机器人"})]})]})})]})}function Zn(){const[n,t]=w([]),[i,a]=w(null),[o,c]=w(!0),[h,u]=w(null),[d,g]=w("all"),[b,z]=w(!0),v=ir(null),[R,x]=w(0);q(()=>{N(),B();const m=setInterval(()=>{N(),B()},3e3);return()=>clearInterval(m)},[d]),q(()=>{b&&n.length>R&&v.current?.scrollIntoView({behavior:"smooth"}),x(n.length)},[n,b]);const N=async()=>{try{const m=d==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${d}`,f=await fetch(m,{credentials:"include"});if(!f.ok)throw new Error("API 请求失败");const y=await f.json();y.success&&Array.isArray(y.data)&&(t(y.data.reverse()),u(null))}catch(m){u(m.message)}finally{c(!1)}},B=async()=>{try{const m=await fetch("/api/logs/stats",{credentials:"include"});if(!m.ok)return;const f=await m.json();f.success&&a(f.data)}catch(m){console.error("Failed to fetch stats:",m)}},M=async(m,f)=>{const y=m?`确定清理 ${m} 天前的日志吗?`:`确定只保留最近 ${f} 条日志吗?`;if(confirm(y))try{const $=await fetch("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:m,maxRecords:f}),credentials:"include"});if(!$.ok)throw new Error("清理失败");const Q=await $.json();Q.success&&(alert(`成功清理 ${Q.data.deletedCount} 条日志`),N(),B())}catch($){alert($.message)}},D=m=>{switch(m){case"info":return"blue";case"warn":return"amber";case"error":return"red";default:return"gray"}},A=m=>{switch(m){case"info":return e(be,{size:14});case"warn":return e(Pr,{size:14});case"error":return e(Lr,{size:14});default:return e(Fr,{size:14})}};return o?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"4",children:[e(_,{size:"8",children:"系统日志"}),e(s,{color:"gray",children:"实时查看系统运行日志"})]}),i&&r(oe,{columns:{initial:"2",sm:"4"},gap:"3",mb:"4",children:[e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",children:i.total}),e(s,{size:"1",color:"gray",children:"总日志数"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"blue",children:i.byLevel.info||0}),e(s,{size:"1",color:"gray",children:"Info"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"amber",children:i.byLevel.warn||0}),e(s,{size:"1",color:"gray",children:"Warn"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"red",children:i.byLevel.error||0}),e(s,{size:"1",color:"gray",children:"Error"})]})})]}),e(S,{mb:"4",children:r(l,{justify:"between",align:"center",p:"3",wrap:"wrap",gap:"3",children:[r(l,{align:"center",gap:"3",wrap:"wrap",children:[r(T.Root,{value:d,onValueChange:g,children:[e(T.Trigger,{style:{minWidth:"120px"}}),r(T.Content,{children:[e(T.Item,{value:"all",children:"所有级别"}),e(T.Item,{value:"info",children:"Info"}),e(T.Item,{value:"warn",children:"Warn"}),e(T.Item,{value:"error",children:"Error"})]})]}),r(l,{as:"span",children:[e(qr,{checked:b,onCheckedChange:m=>z(m)}),e(s,{size:"2",children:"自动滚动"})]})]}),r(l,{gap:"2",children:[r(U,{variant:"soft",onClick:()=>M(7),size:"2",children:[e(Re,{size:14}),"清理7天前"]}),r(U,{variant:"soft",onClick:()=>M(void 0,5e3),size:"2",children:[e(Re,{size:14}),"保留5000条"]}),r(U,{variant:"soft",onClick:()=>N(),size:"2",children:[e(Tr,{size:14}),"刷新"]})]})]})}),e(S,{children:e(I,{p:"4",style:{maxHeight:"600px",overflowY:"auto",backgroundColor:"var(--gray-1)"},children:h?r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",h]})]}):n.length===0?r(l,{direction:"column",align:"center",gap:"3",py:"9",children:[e(se,{size:48,color:"var(--gray-6)"}),e(s,{color:"gray",children:"暂无日志"})]}):r(l,{direction:"column",gap:"2",children:[n.map((m,f)=>e(I,{p:"3",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)",borderLeft:`3px solid var(--${D(m.level)}-9)`},children:r(l,{direction:"column",gap:"1",children:[r(l,{align:"center",gap:"2",children:[e(j,{color:D(m.level),size:"1",children:r(l,{align:"center",gap:"1",children:[A(m.level),m.level.toUpperCase()]})}),e(s,{size:"1",color:"gray",children:new Date(m.timestamp).toLocaleString()}),m.source&&e(j,{variant:"soft",size:"1",children:m.source})]}),e(s,{size:"2",style:{fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:m.message})]})},`${m.timestamp}-${f}`)),e("div",{ref:v})]})})})]})}function he(n){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?he=function(i){return typeof i}:he=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},he(n)}function Kn(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function Xn(n,t){for(var i=0;i<t.length;i++){var a=t[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,a.key,a)}}function Yn(n,t,i){return t&&Xn(n.prototype,t),n}function Qn(n,t){return t&&(he(t)==="object"||typeof t=="function")?t:ue(n)}function $e(n){return $e=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},$e(n)}function ue(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function et(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&Oe(n,t)}function Oe(n,t){return Oe=Object.setPrototypeOf||function(a,o){return a.__proto__=o,a},Oe(n,t)}function ge(n,t,i){return t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i,n}var Ye=(function(n){et(t,n);function t(){var i,a;Kn(this,t);for(var o=arguments.length,c=new Array(o),h=0;h<o;h++)c[h]=arguments[h];return a=Qn(this,(i=$e(t)).call.apply(i,[this].concat(c))),ge(ue(a),"state",{bootstrapped:!1}),ge(ue(a),"_unsubscribe",void 0),ge(ue(a),"handlePersistorState",function(){var u=a.props.persistor,d=u.getState(),g=d.bootstrapped;g&&(a.props.onBeforeLift?Promise.resolve(a.props.onBeforeLift()).finally(function(){return a.setState({bootstrapped:!0})}):a.setState({bootstrapped:!0}),a._unsubscribe&&a._unsubscribe())}),a}return Yn(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})(ar);ge(Ye,"defaultProps",{children:null,loading:null});bn();function rt(){const n=le(c=>c.script.entries),t=le(c=>c.script.loadedScripts),[i,a]=w(!1);q(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:e(Nn,{}),redirect:"/dashboard",meta:{order:0},children:[{key:"dashboard-home",index:!0,path:"",title:"系统概览",icon:e(Er,{className:"w-5 h-5"}),element:e(kn,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:e(Z,{className:"w-5 h-5"}),element:e(Rn,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:e(Gn,{}),meta:{hideInMenu:!0}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:e(ce,{className:"w-5 h-5"}),element:e(qn,{}),meta:{order:3}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:e(se,{className:"w-5 h-5"}),element:e(Zn,{}),meta:{order:4}}]}].forEach(h=>{Hr(h)}),a(!0)},[]);const o=n.length===0||n.length===t.length;return!i||!o?e("div",{className:"flex items-center justify-center h-screen",children:r("div",{className:"text-center",children:[e("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),r("p",{className:"mt-2 text-gray-600",children:["加载中... (",t.length,"/",n.length,")"]})]})}):e(Gr,{})}or(document.getElementById("root")).render(e(lr,{children:e(Zr,{accentColor:"blue",grayColor:"slate",radius:"large",scaling:"100%",children:e(Ye,{loading:null,persistor:Wr,children:e(mn,{store:Jr,children:e(rt,{})})})})}));
|
|
15
|
+
${n.description||""}`,rows:3,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-cyan-500 dark:hover:border-cyan-400 transition-colors"})]})})}function _n({fieldName:n,field:t,value:i,onArrayItemChange:a,renderNestedField:o}){const c=Array.isArray(i)?i:[],h=t.list||[];return e("div",{className:"space-y-3",children:h.map((g,d)=>e("div",{className:"p-3 rounded-lg bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-200 dark:border-indigo-800 hover:border-indigo-300 dark:hover:border-indigo-700 transition-colors",children:r(l,{direction:"column",gap:"2",children:[e(l,{align:"center",gap:"2",children:r(j,{size:"1",variant:"soft",color:"indigo",className:"font-mono",children:["#",d+1]})}),g.description&&e(s,{size:"1",className:"text-indigo-700 dark:text-indigo-300",children:g.description}),e("div",{className:"mt-1",children:o(`${n}[${d}]`,g,c[d],u=>{a?.(n,d,u)})})]})},d))})}function Mn({fieldName:n,field:t,value:i,renderField:a}){const o=t.dict||t.properties||{};return r("div",{className:"rounded-lg border-2 border-blue-200 dark:border-blue-800 bg-gradient-to-br from-blue-50/50 to-cyan-50/50 dark:from-blue-900/10 dark:to-cyan-900/10 overflow-hidden",children:[e("div",{className:"px-4 py-2 bg-blue-100 dark:bg-blue-900/30 border-b border-blue-200 dark:border-blue-800",children:e(l,{align:"center",gap:"2",children:e(K,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})})}),e("div",{className:"p-4 space-y-3",children:Object.entries(o).map(([c,h],g)=>r("div",{children:[e("div",{className:"p-3 rounded-md bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"1",children:[e(s,{size:"2",weight:"bold",className:"text-gray-900 dark:text-gray-100",children:h.key||c}),h.required&&e(s,{size:"2",weight:"bold",color:"red",className:"leading-none",children:"*"})]}),h.description&&e(s,{size:"1",color:"gray",children:h.description}),e("div",{className:"mt-1",children:a(c,h,n)})]})}),g<Object.entries(o).length-1&&e(Ie,{size:"4",className:"my-2"})]},c))})]})}function Dn({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-violet-50 dark:bg-violet-900/20 border border-violet-200 dark:border-violet-800",children:r(l,{direction:"column",gap:"3",children:[e(l,{align:"center",gap:"2",children:e(He,{className:"w-4 h-4 text-violet-600 dark:text-violet-400"})}),e(Q,{size:"2",value:typeof t=="object"?JSON.stringify(t,null,2):t||"{}",onChange:a=>{try{const o=JSON.parse(a.target.value);i(o)}catch{}},placeholder:n.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-violet-500 dark:hover:border-violet-400 transition-colors"}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-violet-600 dark:text-violet-400"}),e(s,{size:"1",className:"text-violet-700 dark:text-violet-300",children:'键值对格式: {"key": "value"}'})]})]})})}function Vn({field:n,value:t,onChange:i}){const a=n.list||[];if(a.length===0)return e(E.Root,{size:"2",value:t||"",onChange:c=>i(c.target.value),placeholder:n.description||"请输入值",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"});const o=a.map(c=>c.default||c.type);return e("div",{className:"p-3 rounded-lg bg-gradient-to-br from-pink-50 to-rose-50 dark:from-pink-900/20 dark:to-rose-900/20 border border-pink-200 dark:border-pink-800",children:r(l,{direction:"column",gap:"2",children:[e(l,{align:"center",gap:"2",children:e(Nr,{className:"w-4 h-4 text-pink-600 dark:text-pink-400"})}),r(T.Root,{size:"2",value:t?.toString()||"",onValueChange:i,children:[e(T.Trigger,{className:"w-full hover:border-pink-500 dark:hover:border-pink-400 transition-colors"}),e(T.Content,{className:"shadow-lg",children:o.map((c,h)=>e(T.Item,{value:String(c),className:"hover:bg-pink-50 dark:hover:bg-pink-900/20 transition-colors",children:e(l,{align:"center",gap:"2",children:e(s,{children:String(c)})})},h))})]})]})})}function Un({fieldName:n,field:t,value:i,onChange:a,renderNestedField:o}){const c=t.list||[];return r("div",{className:"rounded-lg border-2 border-teal-200 dark:border-teal-800 bg-gradient-to-br from-teal-50/50 to-emerald-50/50 dark:from-teal-900/10 dark:to-emerald-900/10 overflow-hidden",children:[e("div",{className:"px-4 py-2 bg-teal-100 dark:bg-teal-900/30 border-b border-teal-200 dark:border-teal-800",children:e(l,{align:"center",gap:"2",children:e(pe,{className:"w-4 h-4 text-teal-600 dark:text-teal-400"})})}),e("div",{className:"p-4 space-y-3",children:c.map((h,g)=>e("div",{className:"p-3 rounded-md bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[h.description&&e(s,{size:"1",color:"gray",children:h.description}),e("div",{className:"mt-1",children:o(`${n}[${g}]`,h,i,a)})]})},g))})]})}function Wn(n){const{field:t}=n;switch(t.type){case"string":return e(In,{...n});case"number":case"integer":return e($n,{...n});case"boolean":return e(On,{...n});case"percent":return e(Tn,{...n});case"date":return e(Fn,{...n});case"regexp":return e(Ln,{...n});case"const":return e(Pn,{...n});case"any":return e(En,{...n});case"list":return e(Bn,{...n});case"array":return e(An,{...n});case"tuple":return e(_n,{...n});case"object":return e(Mn,{...n});case"dict":return e(Dn,{...n});case"union":return e(Vn,{...n});case"intersect":return e(Un,{...n});default:return e(Q,{size:"1",value:typeof n.value=="object"?JSON.stringify(n.value,null,2):n.value||"",onChange:i=>{try{const a=JSON.parse(i.target.value);n.onChange(a)}catch{n.onChange(i.target.value)}},placeholder:t.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function Xe({field:n,value:t,onChange:i}){switch(n.type){case"string":return e(E.Root,{size:"1",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入"});case"number":case"integer":return e(E.Root,{size:"1",type:"number",value:t?.toString()||"",onChange:a=>i(parseFloat(a.target.value)||0),placeholder:n.description||"请输入数字",min:n.min,max:n.max});case"boolean":return r(l,{align:"center",gap:"2",children:[e(qe,{checked:t===!0,onCheckedChange:i}),e(s,{size:"2",color:t?"green":"gray",children:t?"已启用":"已禁用"})]});case"object":{const a=n.dict||n.properties||{};return e(S,{size:"1",children:e(l,{direction:"column",gap:"2",p:"2",children:Object.entries(a).map(([o,c])=>r(I,{children:[e(s,{size:"1",weight:"bold",children:o}),e(Xe,{fieldName:o,field:c,value:t?.[o],onChange:h=>{i({...t,[o]:h})}})]},o))})})}default:return e(Q,{size:"1",value:typeof t=="object"?JSON.stringify(t,null,2):t||"",onChange:a=>{try{i(JSON.parse(a.target.value))}catch{i(a.target.value)}},rows:3,className:"font-mono text-xs"})}}function Jn({pluginName:n,onSuccess:t}){const[i,a]=z({}),[o,c]=z(null),[h,g]=z(void 0),{config:d,schema:u,loading:b,error:w,connected:f,setConfig:R}=Ur(n);q(()=>{d&&a(d)},[d]);const N=async()=>{if(!f){c(null);return}try{await R(i),c("配置已保存成功"),setTimeout(()=>{g(void 0),t?.(),c(null)},1500)}catch(m){console.error("保存配置失败:",m)}},k=(m,y)=>{a(v=>({...v,[m]:y}))},B=(m,y,v)=>{a($=>({...$,[m]:{...$[m]||{},[y]:v}}))},M=(m,y,v)=>{a($=>{const ee=Array.isArray($[m])?[...$[m]]:[];return ee[y]=v,{...$,[m]:ee}})},D=(m,y,v)=>{const $=v?i[v]?.[m]??y.default:i[m]??y.default;return e(Wn,{fieldName:m,field:y,value:$,onChange:v?ie=>B(v,m,ie):ie=>k(m,ie),parentPath:v,onNestedChange:B,onArrayItemChange:M,renderField:D,renderNestedField:(ie,Qe,er,rr)=>e(Xe,{fieldName:ie,field:Qe,value:er,onChange:rr})})},A=u?.properties||u?.dict||{};return!u||!A||Object.keys(A).length===0?null:e(S,{size:"2",className:"mt-4",children:e(ae.Root,{type:"single",collapsible:!0,value:h,onValueChange:g,children:r(ae.Item,{value:"config",className:"border-none",children:[e(ae.Header,{children:e(ae.Trigger,{className:"w-full group",children:r(l,{justify:"between",align:"center",className:"w-full p-3 hover:bg-gray-50 dark:hover:bg-gray-900/50 rounded-lg transition-colors",children:[r(l,{align:"center",gap:"2",children:[e(kr,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e(s,{size:"3",weight:"bold",children:"插件配置"}),r(j,{size:"1",color:"gray",variant:"soft",children:[Object.keys(A).length," 项"]})]}),e(Cr,{className:"w-5 h-5 text-gray-500 transition-transform duration-200 group-data-[state=open]:rotate-180"})]})})}),e(ae.Content,{className:"overflow-hidden data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up",children:r(I,{className:"pt-2 pb-4",children:[o&&e("div",{className:"mb-3 animate-in fade-in slide-in-from-top-2 duration-300",children:r(F.Root,{color:"green",size:"1",className:"shadow-sm",children:[e(F.Icon,{children:e(Sr,{})}),e(F.Text,{className:"font-medium",children:o})]})}),w&&e("div",{className:"mb-3 animate-in fade-in slide-in-from-top-2 duration-300",children:r(F.Root,{color:"red",size:"1",className:"shadow-sm",children:[e(F.Icon,{children:e(te,{})}),e(F.Text,{className:"font-medium",children:w})]})}),e(l,{direction:"column",gap:"3",children:Object.entries(A).map(([m,y])=>{const v=y;return e("div",{className:"group p-3 rounded-lg bg-gray-50 dark:bg-gray-900/50 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"1",children:[e(s,{size:"2",weight:"bold",className:"text-gray-900 dark:text-gray-100",children:v.key||m}),v.required&&e(s,{size:"2",weight:"bold",color:"red",className:"leading-none",children:"*"})]}),v.description&&e(s,{size:"1",color:"gray",className:"leading-relaxed",children:v.description}),e("div",{className:"mt-1",children:D(v.key||m,v)})]})},m)})}),r(l,{gap:"2",justify:"end",className:"mt-4 pt-3 border-t border-gray-200 dark:border-gray-800",children:[r(U,{size:"2",variant:"soft",onClick:()=>g(void 0),disabled:b,className:"hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors",children:[e(jr,{className:"w-4 h-4"}),"取消"]}),e(U,{size:"2",onClick:N,disabled:b,className:"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white transition-colors shadow-sm",children:b?r(me,{children:[e(fe,{}),e("span",{children:"保存中..."})]}):r(me,{children:[e(Rr,{className:"w-4 h-4"}),e("span",{children:"保存配置"})]})})]})]})})]})})})}const{Flex:p,Box:H,Spinner:Hn,Text:x,Callout:Ne,Heading:X,Badge:V,Grid:Ue,Card:P,Button:We,Code:Z,Separator:Y}=Te;function Gn(){const{name:n}=Kr(),t=Fe(),[i,a]=z(null),[o,c]=z(!0),[h,g]=z(null);q(()=>{n&&d(n)},[n]);const d=async u=>{try{const b=await fetch(`/api/plugins/${encodeURIComponent(u)}`,{credentials:"include"});if(!b.ok)throw new Error("API 请求失败");const w=await b.json();if(w.success)a(w.data),g(null);else throw new Error("数据格式错误")}catch(b){g(b.message)}finally{c(!1)}};return o?e(p,{align:"center",justify:"center",className:"h-full",children:r(p,{direction:"column",align:"center",gap:"3",children:[e(Hn,{size:"3"}),e(x,{size:"2",color:"gray",children:"加载中..."})]})}):h||!i?r(H,{children:[r(We,{variant:"ghost",onClick:()=>t("/plugins"),mb:"4",size:"2",children:[e(Le,{className:"w-4 h-4"}),"返回"]}),r(Ne.Root,{color:"red",children:[e(Ne.Icon,{children:e(te,{})}),r(Ne.Text,{children:["加载失败: ",h||"插件不存在"]})]})]}):r(H,{children:[r(p,{direction:"column",gap:"3",mb:"4",children:[r(We,{variant:"ghost",onClick:()=>t("/plugins"),size:"2",children:[e(Le,{className:"w-4 h-4"}),"返回"]}),r(p,{align:"center",gap:"3",children:[e(p,{align:"center",justify:"center",className:"w-12 h-12 rounded-xl bg-blue-500/10 dark:bg-blue-400/10",children:e(K,{className:"w-6 h-6 text-blue-600 dark:text-blue-400"})}),r(p,{direction:"column",gap:"1",children:[r(p,{align:"center",gap:"2",children:[e(X,{size:"5",children:i.name}),e(V,{color:i.status==="active"?"green":"gray",size:"1",children:i.status==="active"?"运行中":"已停止"})]}),e(x,{size:"2",color:"gray",children:i.description||"暂无描述"})]})]})]}),e(Jn,{pluginName:i.name,onSuccess:()=>{}}),e(Y,{size:"4",my:"4"}),r(Ue,{columns:{initial:"2",sm:"3",md:"6"},gap:"2",mb:"4",children:[e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Se,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.commandCount}),e(x,{size:"1",color:"gray",children:"命令"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Je,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.componentCount}),e(x,{size:"1",color:"gray",children:"组件"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(pe,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.middlewareCount}),e(x,{size:"1",color:"gray",children:"中间件"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(je,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.contextCount}),e(x,{size:"1",color:"gray",children:"上下文"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Ce,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.cronCount}),e(x,{size:"1",color:"gray",children:"定时任务"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(se,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.definitionCount}),e(x,{size:"1",color:"gray",children:"数据模型"})]})})]}),r(Ue,{columns:{initial:"1",md:"2"},gap:"3",children:[i.commands.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(Se,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e(X,{size:"3",children:"命令"}),e(V,{size:"1",children:i.commands.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.commands.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-3",children:r(p,{direction:"column",gap:"2",children:[e(Z,{size:"2",weight:"bold",children:u.name}),u.desc&&u.desc.length>0&&e(p,{direction:"column",gap:"1",children:u.desc.map((w,f)=>e(x,{size:"1",color:"gray",children:w},f))}),u.usage&&u.usage.length>0&&r(p,{direction:"column",gap:"1",children:[e(x,{size:"1",weight:"bold",color:"blue",children:"用法:"}),u.usage.map((w,f)=>e(Z,{size:"1",variant:"soft",children:w},f))]}),u.examples&&u.examples.length>0&&r(p,{direction:"column",gap:"1",children:[e(x,{size:"1",weight:"bold",color:"green",children:"示例:"}),u.examples.map((w,f)=>e(Z,{size:"1",variant:"soft",color:"green",children:w},f))]})]})},b))})]})}),i.components.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(H,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(X,{size:"3",children:"组件"}),e(V,{size:"1",children:i.components.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.components.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[r(p,{align:"center",gap:"2",children:[e(Z,{size:"2",children:u.name}),e(V,{size:"1",variant:"soft",children:u.type})]}),r(x,{size:"1",color:"gray",children:["属性数: ",Object.keys(u.props).length]})]})},b))})]})}),i.middlewares.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(pe,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(X,{size:"3",children:"中间件"}),e(V,{size:"1",children:i.middlewares.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.middlewares.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{align:"center",gap:"2",children:[e(Z,{size:"2",children:u.id}),e(V,{size:"1",variant:"soft",children:u.type})]})},b))})]})}),i.contexts.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(je,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"}),e(X,{size:"3",children:"上下文"}),e(V,{size:"1",children:i.contexts.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.contexts.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[e(Z,{size:"2",children:u.name}),e(x,{size:"1",color:"gray",children:u.description})]})},b))})]})}),i.crons.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(Ce,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e(X,{size:"3",children:"定时任务"}),e(V,{size:"1",children:i.crons.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.crons.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{justify:"between",align:"center",children:[r(p,{direction:"column",gap:"1",children:[e(Z,{size:"2",children:u.id}),e(x,{size:"1",color:"gray",children:u.pattern})]}),e(V,{color:u.running?"green":"gray",size:"1",children:u.running?"运行中":"已停止"})]})},b))})]})}),i.definitions.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(se,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(X,{size:"3",children:"数据模型"}),e(V,{size:"1",children:i.definitions.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.definitions.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[e(Z,{size:"2",children:u.name}),r(x,{size:"1",color:"gray",children:["字段: ",u.fields.join(", ")]})]})},b))})]})})]})]})}function qn(){const[n,t]=z([]),[i,a]=z(!0),[o,c]=z(null);q(()=>{h();const g=setInterval(h,5e3);return()=>clearInterval(g)},[]);const h=async()=>{try{const g=await fetch("/api/bots",{credentials:"include"});if(!g.ok)throw new Error("API 请求失败");const d=await g.json();if(d.success)t(d.data),c(null);else throw new Error("数据格式错误")}catch(g){c(g.message)}finally{a(!1)}};return i?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):o?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",o]})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"6",children:[e(_,{size:"8",children:"机器人管理"}),r(l,{align:"center",gap:"2",children:[r(s,{color:"gray",children:["共 ",n.length," 个机器人,"]}),e(j,{color:"green",children:n.filter(g=>g.connected).length}),e(s,{color:"gray",children:"个在线"})]})]}),e(Ie,{size:"4",mb:"6"}),e(oe,{columns:{initial:"1",sm:"2",lg:"3"},gap:"4",children:n.map((g,d)=>e(S,{children:r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(I,{style:{padding:"8px",borderRadius:"8px",backgroundColor:g.connected?"var(--green-3)":"var(--gray-3)"},children:e(ce,{size:20,color:g.connected?"var(--green-9)":"var(--gray-9)"})}),e(s,{size:"4",weight:"bold",children:g.name})]}),r(I,{style:{position:"relative"},children:[e(j,{color:g.connected?"green":"gray",children:e(l,{align:"center",gap:"1",children:g.connected?r(me,{children:[e(Ir,{size:12}),"在线"]}):r(me,{children:[e($r,{size:12}),"离线"]})})}),g.connected&&e(I,{style:{position:"absolute",top:"-4px",right:"-4px",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"var(--green-9)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})]})]}),r(l,{align:"center",gap:"2",children:[e(s,{size:"2",color:"gray",children:"适配器:"}),e(j,{variant:"outline",children:g.adapter})]}),e(Ie,{size:"4"}),r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(ke,{size:16,color:g.status==="online"?"var(--green-9)":"var(--gray-9)"}),e(s,{size:"2",color:"gray",children:"运行状态"})]}),e(j,{color:g.status==="online"?"green":"gray",children:g.status==="online"?"运行中":"已停止"})]}),r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(K,{size:16,color:"var(--blue-9)"}),e(s,{size:"2",color:"gray",children:"适配器类型"})]}),e(s,{size:"2",weight:"medium",children:g.adapter})]}),r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(Or,{size:16,color:"var(--purple-9)"}),e(s,{size:"2",color:"gray",children:"连接状态"})]}),e(s,{size:"2",weight:"medium",color:g.connected?"green":"gray",children:g.connected?"已连接":"未连接"})]})]})]})},`${g.adapter}-${g.name}-${d}`))}),n.length===0&&e(S,{children:r(l,{direction:"column",align:"center",gap:"4",py:"9",children:[e(ce,{size:64,color:"var(--gray-6)"}),r(l,{direction:"column",align:"center",gap:"2",children:[e(_,{size:"4",children:"暂无机器人"}),e(s,{color:"gray",children:"请先配置并启动机器人"})]})]})})]})}function Zn(){const[n,t]=z([]),[i,a]=z(null),[o,c]=z(!0),[h,g]=z(null),[d,u]=z("all"),[b,w]=z(!0),f=ir(null),[R,N]=z(0);q(()=>{k(),B();const m=setInterval(()=>{k(),B()},3e3);return()=>clearInterval(m)},[d]),q(()=>{b&&n.length>R&&f.current?.scrollIntoView({behavior:"smooth"}),N(n.length)},[n,b]);const k=async()=>{try{const m=d==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${d}`,y=await fetch(m,{credentials:"include"});if(!y.ok)throw new Error("API 请求失败");const v=await y.json();v.success&&Array.isArray(v.data)&&(t(v.data.reverse()),g(null))}catch(m){g(m.message)}finally{c(!1)}},B=async()=>{try{const m=await fetch("/api/logs/stats",{credentials:"include"});if(!m.ok)return;const y=await m.json();y.success&&a(y.data)}catch(m){console.error("Failed to fetch stats:",m)}},M=async(m,y)=>{const v=m?`确定清理 ${m} 天前的日志吗?`:`确定只保留最近 ${y} 条日志吗?`;if(confirm(v))try{const $=await fetch("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:m,maxRecords:y}),credentials:"include"});if(!$.ok)throw new Error("清理失败");const ee=await $.json();ee.success&&(alert(`成功清理 ${ee.data.deletedCount} 条日志`),k(),B())}catch($){alert($.message)}},D=m=>{switch(m){case"info":return"blue";case"warn":return"amber";case"error":return"red";default:return"gray"}},A=m=>{switch(m){case"info":return e(be,{size:14});case"warn":return e(Pr,{size:14});case"error":return e(Lr,{size:14});default:return e(Fr,{size:14})}};return o?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"4",children:[e(_,{size:"8",children:"系统日志"}),e(s,{color:"gray",children:"实时查看系统运行日志"})]}),i&&r(oe,{columns:{initial:"2",sm:"4"},gap:"3",mb:"4",children:[e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",children:i.total}),e(s,{size:"1",color:"gray",children:"总日志数"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"blue",children:i.byLevel.info||0}),e(s,{size:"1",color:"gray",children:"Info"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"amber",children:i.byLevel.warn||0}),e(s,{size:"1",color:"gray",children:"Warn"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"red",children:i.byLevel.error||0}),e(s,{size:"1",color:"gray",children:"Error"})]})})]}),e(S,{mb:"4",children:r(l,{justify:"between",align:"center",p:"3",wrap:"wrap",gap:"3",children:[r(l,{align:"center",gap:"3",wrap:"wrap",children:[r(T.Root,{value:d,onValueChange:u,children:[e(T.Trigger,{style:{minWidth:"120px"}}),r(T.Content,{children:[e(T.Item,{value:"all",children:"所有级别"}),e(T.Item,{value:"info",children:"Info"}),e(T.Item,{value:"warn",children:"Warn"}),e(T.Item,{value:"error",children:"Error"})]})]}),r(l,{as:"span",children:[e(qr,{checked:b,onCheckedChange:m=>w(m)}),e(s,{size:"2",children:"自动滚动"})]})]}),r(l,{gap:"2",children:[r(U,{variant:"soft",onClick:()=>M(7),size:"2",children:[e(Re,{size:14}),"清理7天前"]}),r(U,{variant:"soft",onClick:()=>M(void 0,5e3),size:"2",children:[e(Re,{size:14}),"保留5000条"]}),r(U,{variant:"soft",onClick:()=>k(),size:"2",children:[e(Tr,{size:14}),"刷新"]})]})]})}),e(S,{children:e(I,{p:"4",style:{maxHeight:"600px",overflowY:"auto",backgroundColor:"var(--gray-1)"},children:h?r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",h]})]}):n.length===0?r(l,{direction:"column",align:"center",gap:"3",py:"9",children:[e(se,{size:48,color:"var(--gray-6)"}),e(s,{color:"gray",children:"暂无日志"})]}):r(l,{direction:"column",gap:"2",children:[n.map((m,y)=>e(I,{p:"3",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)",borderLeft:`3px solid var(--${D(m.level)}-9)`},children:r(l,{direction:"column",gap:"1",children:[r(l,{align:"center",gap:"2",children:[e(j,{color:D(m.level),size:"1",children:r(l,{align:"center",gap:"1",children:[A(m.level),m.level.toUpperCase()]})}),e(s,{size:"1",color:"gray",children:new Date(m.timestamp).toLocaleString()}),m.source&&e(j,{variant:"soft",size:"1",children:m.source})]}),e(s,{size:"2",style:{fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:m.message})]})},`${m.timestamp}-${y}`)),e("div",{ref:f})]})})})]})}function he(n){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?he=function(i){return typeof i}:he=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},he(n)}function Kn(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function Xn(n,t){for(var i=0;i<t.length;i++){var a=t[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,a.key,a)}}function Yn(n,t,i){return t&&Xn(n.prototype,t),n}function Qn(n,t){return t&&(he(t)==="object"||typeof t=="function")?t:ue(n)}function $e(n){return $e=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},$e(n)}function ue(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function et(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&Oe(n,t)}function Oe(n,t){return Oe=Object.setPrototypeOf||function(a,o){return a.__proto__=o,a},Oe(n,t)}function ge(n,t,i){return t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i,n}var Ye=(function(n){et(t,n);function t(){var i,a;Kn(this,t);for(var o=arguments.length,c=new Array(o),h=0;h<o;h++)c[h]=arguments[h];return a=Qn(this,(i=$e(t)).call.apply(i,[this].concat(c))),ge(ue(a),"state",{bootstrapped:!1}),ge(ue(a),"_unsubscribe",void 0),ge(ue(a),"handlePersistorState",function(){var g=a.props.persistor,d=g.getState(),u=d.bootstrapped;u&&(a.props.onBeforeLift?Promise.resolve(a.props.onBeforeLift()).finally(function(){return a.setState({bootstrapped:!0})}):a.setState({bootstrapped:!0}),a._unsubscribe&&a._unsubscribe())}),a}return Yn(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})(ar);ge(Ye,"defaultProps",{children:null,loading:null});bn();function rt(){const n=le(c=>c.script.entries),t=le(c=>c.script.loadedScripts),[i,a]=z(!1);q(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:e(Nn,{}),redirect:"/dashboard",meta:{order:0},children:[{key:"dashboard-home",index:!0,path:"",title:"系统概览",icon:e(Er,{className:"w-5 h-5"}),element:e(kn,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:e(K,{className:"w-5 h-5"}),element:e(Rn,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:e(Gn,{}),meta:{hideInMenu:!0}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:e(ce,{className:"w-5 h-5"}),element:e(qn,{}),meta:{order:3}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:e(se,{className:"w-5 h-5"}),element:e(Zn,{}),meta:{order:4}}]}].forEach(h=>{Hr(h)}),a(!0)},[]);const o=n.length===0||n.length===t.length;return!i||!o?e("div",{className:"flex items-center justify-center h-screen",children:r("div",{className:"text-center",children:[e("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),r("p",{className:"mt-2 text-gray-600",children:["加载中... (",t.length,"/",n.length,")"]})]})}):e(Gr,{})}or(document.getElementById("root")).render(e(lr,{children:e(Zr,{accentColor:"blue",grayColor:"slate",radius:"large",scaling:"100%",children:e(Ye,{loading:null,persistor:Wr,children:e(mn,{store:Jr,children:e(rt,{})})})})}));
|
package/lib/bin.d.ts
CHANGED
package/lib/bin.js
CHANGED
|
@@ -1,21 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import * as vite from 'vite';
|
|
3
|
+
import { existsSync, promises } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
7
|
+
|
|
8
|
+
async function build2(root, config = {}) {
|
|
9
|
+
if (!existsSync(root + "/client")) return;
|
|
10
|
+
const outDir = root + "/dist";
|
|
11
|
+
if (existsSync(outDir)) {
|
|
12
|
+
await promises.rm(outDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
const maybeFiles = [
|
|
15
|
+
join(root, "client", "index.tsx"),
|
|
16
|
+
join(root, "client", "index.ts"),
|
|
17
|
+
join(root, "client", "index.js"),
|
|
18
|
+
join(root, "client", "index.jsx")
|
|
19
|
+
];
|
|
20
|
+
const entry = maybeFiles.find((file) => existsSync(file));
|
|
21
|
+
if (!entry) {
|
|
22
|
+
throw new Error("No entry file found");
|
|
23
|
+
}
|
|
24
|
+
await promises.mkdir(root + "/dist", { recursive: true });
|
|
25
|
+
const results = await vite.build(vite.mergeConfig({
|
|
26
|
+
root,
|
|
27
|
+
build: {
|
|
28
|
+
write: false,
|
|
29
|
+
outDir: "dist",
|
|
30
|
+
assetsDir: "",
|
|
31
|
+
minify: true,
|
|
32
|
+
emptyOutDir: true,
|
|
33
|
+
commonjsOptions: {
|
|
34
|
+
strictRequires: true
|
|
35
|
+
},
|
|
36
|
+
lib: {
|
|
37
|
+
entry,
|
|
38
|
+
fileName: "index",
|
|
39
|
+
formats: ["es"]
|
|
40
|
+
},
|
|
41
|
+
rollupOptions: {
|
|
42
|
+
makeAbsoluteExternalsRelative: true,
|
|
43
|
+
external: [
|
|
44
|
+
"react",
|
|
45
|
+
"react-dom",
|
|
46
|
+
"react/jsx-runtime",
|
|
47
|
+
"react/jsx-dev-runtime",
|
|
48
|
+
"radix-ui",
|
|
49
|
+
"@radix-ui/themes",
|
|
50
|
+
"lucide-react",
|
|
51
|
+
"@zhin.js/client"
|
|
52
|
+
],
|
|
53
|
+
resolve: {
|
|
54
|
+
alias: {
|
|
55
|
+
"react/jsx-runtime": root + "/react-jsx-runtime.js",
|
|
56
|
+
"react/jsx-dev-runtime": root + "/react-jsx-dev-runtime.js",
|
|
57
|
+
"react": root + "/react.js",
|
|
58
|
+
"react-dom": root + "/react-dom.js",
|
|
59
|
+
"radix-ui": root + "/radix-ui.js",
|
|
60
|
+
"@radix-ui/themes": root + "/radix-ui-themes.js"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
output: {
|
|
64
|
+
format: "iife"
|
|
13
65
|
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
plugins: [
|
|
69
|
+
react(),
|
|
70
|
+
tailwindcss()
|
|
71
|
+
],
|
|
72
|
+
define: {
|
|
73
|
+
"process.env.NODE_ENV": '"production"'
|
|
74
|
+
}
|
|
75
|
+
}, config));
|
|
76
|
+
for (const item of results[0].output) {
|
|
77
|
+
if (item.fileName === "index.mjs") item.fileName = "index.js";
|
|
78
|
+
const dest = root + "/dist/" + item.fileName;
|
|
79
|
+
if (item.type === "asset") {
|
|
80
|
+
await promises.writeFile(dest, item.source);
|
|
81
|
+
} else {
|
|
82
|
+
const result = await vite.transformWithEsbuild(item.code, dest, {
|
|
83
|
+
minifyWhitespace: true,
|
|
84
|
+
charset: "utf8"
|
|
85
|
+
});
|
|
86
|
+
await promises.writeFile(dest, result.code);
|
|
14
87
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/bin.ts
|
|
92
|
+
var args = process.argv.slice(2);
|
|
93
|
+
var command = args[0];
|
|
94
|
+
async function main() {
|
|
95
|
+
try {
|
|
96
|
+
switch (command) {
|
|
97
|
+
case "build":
|
|
98
|
+
console.log("\u{1F528} Building plugin client...");
|
|
99
|
+
await build2(process.cwd());
|
|
100
|
+
break;
|
|
18
101
|
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error("\u274C Build failed:", error);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
19
106
|
}
|
|
20
107
|
main();
|
|
21
|
-
//# sourceMappingURL=bin.js.map
|
package/lib/build.d.ts
CHANGED