@zhin.js/console 1.0.21 → 1.0.23
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 +20 -0
- package/README.md +4 -4
- package/client/components.json +17 -0
- package/client/index.html +1 -1
- package/client/src/components/PluginConfigForm/BasicFieldRenderers.tsx +89 -180
- package/client/src/components/PluginConfigForm/CollectionFieldRenderers.tsx +97 -200
- package/client/src/components/PluginConfigForm/CompositeFieldRenderers.tsx +31 -70
- package/client/src/components/PluginConfigForm/FieldRenderer.tsx +27 -77
- package/client/src/components/PluginConfigForm/NestedFieldRenderer.tsx +33 -53
- package/client/src/components/PluginConfigForm/index.tsx +71 -173
- package/client/src/components/ui/accordion.tsx +54 -0
- package/client/src/components/ui/alert.tsx +62 -0
- package/client/src/components/ui/avatar.tsx +41 -0
- package/client/src/components/ui/badge.tsx +32 -0
- package/client/src/components/ui/button.tsx +50 -0
- package/client/src/components/ui/card.tsx +50 -0
- package/client/src/components/ui/checkbox.tsx +25 -0
- package/client/src/components/ui/dialog.tsx +87 -0
- package/client/src/components/ui/dropdown-menu.tsx +97 -0
- package/client/src/components/ui/input.tsx +21 -0
- package/client/src/components/ui/scroll-area.tsx +43 -0
- package/client/src/components/ui/select.tsx +127 -0
- package/client/src/components/ui/separator.tsx +23 -0
- package/client/src/components/ui/skeleton.tsx +12 -0
- package/client/src/components/ui/switch.tsx +26 -0
- package/client/src/components/ui/tabs.tsx +52 -0
- package/client/src/components/ui/textarea.tsx +20 -0
- package/client/src/components/ui/tooltip.tsx +27 -0
- package/client/src/layouts/dashboard.tsx +91 -221
- package/client/src/main.tsx +38 -42
- package/client/src/pages/dashboard-bots.tsx +91 -137
- package/client/src/pages/dashboard-home.tsx +133 -204
- package/client/src/pages/dashboard-logs.tsx +125 -196
- package/client/src/pages/dashboard-plugin-detail.tsx +261 -329
- package/client/src/pages/dashboard-plugins.tsx +108 -105
- package/client/src/style.css +156 -865
- package/client/src/theme/index.ts +60 -35
- package/client/tailwind.config.js +78 -69
- package/dist/client.js +1 -1
- package/dist/cva.js +47 -0
- package/dist/index.html +1 -1
- package/dist/index.js +6 -6
- package/dist/react-router.js +7121 -5585
- package/dist/react.js +192 -149
- package/dist/style.css +2 -2
- package/lib/bin.js +2 -2
- package/lib/build.js +2 -2
- package/lib/index.d.ts +0 -3
- package/lib/index.js +160 -205
- package/lib/transform.d.ts +26 -0
- package/lib/transform.js +78 -0
- package/lib/websocket.d.ts +0 -1
- package/package.json +9 -8
- package/dist/radix-ui-themes.js +0 -9305
- package/lib/dev.d.ts +0 -18
- package/lib/dev.js +0 -87
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
import { useNavigate } from 'react-router'
|
|
3
|
-
import {Flex,Box,Spinner,Text,Callout,Heading,Badge,Grid,Card,Button} from '@radix-ui/themes'
|
|
4
3
|
import { Bot, AlertCircle, Activity, Package, Clock, Cpu, MemoryStick, FileText, TrendingUp } from 'lucide-react'
|
|
4
|
+
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../components/ui/card'
|
|
5
|
+
import { Badge } from '../components/ui/badge'
|
|
6
|
+
import { Button } from '../components/ui/button'
|
|
7
|
+
import { Alert, AlertDescription } from '../components/ui/alert'
|
|
8
|
+
import { Skeleton } from '../components/ui/skeleton'
|
|
5
9
|
|
|
6
10
|
interface Stats {
|
|
7
11
|
plugins: { total: number; active: number }
|
|
@@ -14,16 +18,8 @@ interface Stats {
|
|
|
14
18
|
|
|
15
19
|
interface SystemStatus {
|
|
16
20
|
uptime: number
|
|
17
|
-
memory: {
|
|
18
|
-
|
|
19
|
-
heapTotal: number
|
|
20
|
-
heapUsed: number
|
|
21
|
-
external: number
|
|
22
|
-
}
|
|
23
|
-
cpu: {
|
|
24
|
-
user: number
|
|
25
|
-
system: number
|
|
26
|
-
}
|
|
21
|
+
memory: { rss: number; heapTotal: number; heapUsed: number; external: number }
|
|
22
|
+
cpu: { user: number; system: number }
|
|
27
23
|
platform: string
|
|
28
24
|
nodeVersion: string
|
|
29
25
|
}
|
|
@@ -47,12 +43,9 @@ export default function DashboardHome() {
|
|
|
47
43
|
fetch('/api/stats', { credentials: 'include' }),
|
|
48
44
|
fetch('/api/system/status', { credentials: 'include' })
|
|
49
45
|
])
|
|
50
|
-
|
|
51
46
|
if (!statsRes.ok || !statusRes.ok) throw new Error('API 请求失败')
|
|
52
|
-
|
|
53
47
|
const statsData = await statsRes.json()
|
|
54
48
|
const statusData = await statusRes.json()
|
|
55
|
-
|
|
56
49
|
if (statsData.success && statusData.success) {
|
|
57
50
|
setStats(statsData.data)
|
|
58
51
|
setSystemStatus(statusData.data)
|
|
@@ -72,230 +65,166 @@ export default function DashboardHome() {
|
|
|
72
65
|
return `${days}天 ${hours}小时 ${minutes}分钟`
|
|
73
66
|
}
|
|
74
67
|
|
|
75
|
-
const formatMemory = (bytes: number) => {
|
|
76
|
-
return `${(bytes / 1024 / 1024).toFixed(2)} MB`
|
|
77
|
-
}
|
|
68
|
+
const formatMemory = (bytes: number) => `${(bytes / 1024 / 1024).toFixed(2)} MB`
|
|
78
69
|
|
|
79
70
|
if (loading) {
|
|
80
71
|
return (
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
</
|
|
86
|
-
</
|
|
72
|
+
<div className="space-y-6">
|
|
73
|
+
<div><Skeleton className="h-8 w-48" /><Skeleton className="h-4 w-64 mt-2" /></div>
|
|
74
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
75
|
+
{[...Array(4)].map((_, i) => <Skeleton key={i} className="h-32" />)}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
87
78
|
)
|
|
88
79
|
}
|
|
89
80
|
|
|
90
81
|
if (error) {
|
|
91
82
|
return (
|
|
92
|
-
<
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
加载失败: {error}
|
|
99
|
-
</Callout.Text>
|
|
100
|
-
</Callout.Root>
|
|
101
|
-
</Flex>
|
|
83
|
+
<div className="flex items-center justify-center h-full">
|
|
84
|
+
<Alert variant="destructive" className="max-w-md">
|
|
85
|
+
<AlertCircle className="h-4 w-4" />
|
|
86
|
+
<AlertDescription>加载失败: {error}</AlertDescription>
|
|
87
|
+
</Alert>
|
|
88
|
+
</div>
|
|
102
89
|
)
|
|
103
90
|
}
|
|
104
91
|
|
|
105
92
|
return (
|
|
106
|
-
<
|
|
107
|
-
{/*
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
</
|
|
112
|
-
|
|
113
|
-
{/*
|
|
114
|
-
<
|
|
93
|
+
<div className="space-y-6">
|
|
94
|
+
{/* Page header */}
|
|
95
|
+
<div>
|
|
96
|
+
<h1 className="text-2xl font-bold tracking-tight">系统概览</h1>
|
|
97
|
+
<p className="text-muted-foreground">实时监控您的机器人框架运行状态</p>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
{/* Stats cards */}
|
|
101
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
115
102
|
<Card>
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<Text size="1" color="gray">个活跃</Text>
|
|
127
|
-
</Flex>
|
|
128
|
-
</Flex>
|
|
103
|
+
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
104
|
+
<CardTitle className="text-sm font-medium text-muted-foreground">插件总数</CardTitle>
|
|
105
|
+
<Package className="h-4 w-4 text-muted-foreground" />
|
|
106
|
+
</CardHeader>
|
|
107
|
+
<CardContent>
|
|
108
|
+
<div className="text-3xl font-bold">{stats?.plugins.total || 0}</div>
|
|
109
|
+
<p className="text-xs text-muted-foreground mt-1">
|
|
110
|
+
<Badge variant="secondary" className="mr-1">{stats?.plugins.active || 0}</Badge>个活跃
|
|
111
|
+
</p>
|
|
112
|
+
</CardContent>
|
|
129
113
|
</Card>
|
|
130
114
|
|
|
131
115
|
<Card>
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
{stats?.bots.online || 0}
|
|
140
|
-
</
|
|
141
|
-
</
|
|
116
|
+
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
117
|
+
<CardTitle className="text-sm font-medium text-muted-foreground">机器人</CardTitle>
|
|
118
|
+
<Bot className="h-4 w-4 text-muted-foreground" />
|
|
119
|
+
</CardHeader>
|
|
120
|
+
<CardContent>
|
|
121
|
+
<div className="text-3xl font-bold">{stats?.bots.total || 0}</div>
|
|
122
|
+
<p className="text-xs text-muted-foreground mt-1">
|
|
123
|
+
<Badge variant="success" className="mr-1">{stats?.bots.online || 0}</Badge>个在线
|
|
124
|
+
</p>
|
|
125
|
+
</CardContent>
|
|
142
126
|
</Card>
|
|
143
127
|
|
|
144
128
|
<Card>
|
|
145
|
-
<
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<
|
|
151
|
-
<
|
|
152
|
-
</
|
|
129
|
+
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
130
|
+
<CardTitle className="text-sm font-medium text-muted-foreground">命令数量</CardTitle>
|
|
131
|
+
<Activity className="h-4 w-4 text-muted-foreground" />
|
|
132
|
+
</CardHeader>
|
|
133
|
+
<CardContent>
|
|
134
|
+
<div className="text-3xl font-bold">{stats?.commands || 0}</div>
|
|
135
|
+
<p className="text-xs text-muted-foreground mt-1">可用命令</p>
|
|
136
|
+
</CardContent>
|
|
153
137
|
</Card>
|
|
154
138
|
|
|
155
139
|
<Card>
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
<
|
|
162
|
-
<
|
|
163
|
-
</
|
|
140
|
+
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
141
|
+
<CardTitle className="text-sm font-medium text-muted-foreground">组件数量</CardTitle>
|
|
142
|
+
<TrendingUp className="h-4 w-4 text-muted-foreground" />
|
|
143
|
+
</CardHeader>
|
|
144
|
+
<CardContent>
|
|
145
|
+
<div className="text-3xl font-bold">{stats?.components || 0}</div>
|
|
146
|
+
<p className="text-xs text-muted-foreground mt-1">已注册组件</p>
|
|
147
|
+
</CardContent>
|
|
164
148
|
</Card>
|
|
165
|
-
</
|
|
149
|
+
</div>
|
|
166
150
|
|
|
167
|
-
{/*
|
|
168
|
-
<
|
|
151
|
+
{/* System status */}
|
|
152
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
169
153
|
<Card>
|
|
170
|
-
<
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
</
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<Flex align="center" gap="2">
|
|
189
|
-
<Cpu size={16} color="var(--gray-9)" />
|
|
190
|
-
<Text size="2">平台</Text>
|
|
191
|
-
</Flex>
|
|
192
|
-
<Badge variant="soft">
|
|
193
|
-
{systemStatus?.platform || '-'}
|
|
194
|
-
</Badge>
|
|
195
|
-
</Flex>
|
|
196
|
-
|
|
197
|
-
<Flex justify="between" align="center">
|
|
198
|
-
<Flex align="center" gap="2">
|
|
199
|
-
<Activity size={16} color="var(--gray-9)" />
|
|
200
|
-
<Text size="2">Node 版本</Text>
|
|
201
|
-
</Flex>
|
|
202
|
-
<Badge variant="soft">
|
|
203
|
-
{systemStatus?.nodeVersion || '-'}
|
|
204
|
-
</Badge>
|
|
205
|
-
</Flex>
|
|
206
|
-
</Flex>
|
|
207
|
-
</Flex>
|
|
154
|
+
<CardHeader>
|
|
155
|
+
<CardTitle>系统信息</CardTitle>
|
|
156
|
+
<CardDescription>服务器运行状态</CardDescription>
|
|
157
|
+
</CardHeader>
|
|
158
|
+
<CardContent className="space-y-3">
|
|
159
|
+
<div className="flex justify-between items-center">
|
|
160
|
+
<div className="flex items-center gap-2 text-sm"><Clock className="h-4 w-4 text-muted-foreground" />运行时间</div>
|
|
161
|
+
<Badge variant="secondary">{systemStatus ? formatUptime(systemStatus.uptime) : '-'}</Badge>
|
|
162
|
+
</div>
|
|
163
|
+
<div className="flex justify-between items-center">
|
|
164
|
+
<div className="flex items-center gap-2 text-sm"><Cpu className="h-4 w-4 text-muted-foreground" />平台</div>
|
|
165
|
+
<Badge variant="secondary">{systemStatus?.platform || '-'}</Badge>
|
|
166
|
+
</div>
|
|
167
|
+
<div className="flex justify-between items-center">
|
|
168
|
+
<div className="flex items-center gap-2 text-sm"><Activity className="h-4 w-4 text-muted-foreground" />Node 版本</div>
|
|
169
|
+
<Badge variant="secondary">{systemStatus?.nodeVersion || '-'}</Badge>
|
|
170
|
+
</div>
|
|
171
|
+
</CardContent>
|
|
208
172
|
</Card>
|
|
209
173
|
|
|
210
174
|
<Card>
|
|
211
|
-
<
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
</
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
<Flex align="center" gap="2">
|
|
230
|
-
<MemoryStick size={16} color="var(--gray-9)" />
|
|
231
|
-
<Text size="2">总堆内存</Text>
|
|
232
|
-
</Flex>
|
|
233
|
-
<Badge variant="soft">
|
|
234
|
-
{systemStatus ? formatMemory(systemStatus.memory.heapTotal) : '-'}
|
|
235
|
-
</Badge>
|
|
236
|
-
</Flex>
|
|
237
|
-
|
|
238
|
-
<Flex justify="between" align="center">
|
|
239
|
-
<Flex align="center" gap="2">
|
|
240
|
-
<MemoryStick size={16} color="var(--gray-9)" />
|
|
241
|
-
<Text size="2">RSS</Text>
|
|
242
|
-
</Flex>
|
|
243
|
-
<Badge variant="soft">
|
|
244
|
-
{systemStatus ? formatMemory(systemStatus.memory.rss) : '-'}
|
|
245
|
-
</Badge>
|
|
246
|
-
</Flex>
|
|
247
|
-
</Flex>
|
|
248
|
-
</Flex>
|
|
175
|
+
<CardHeader>
|
|
176
|
+
<CardTitle>资源使用</CardTitle>
|
|
177
|
+
<CardDescription>内存使用情况</CardDescription>
|
|
178
|
+
</CardHeader>
|
|
179
|
+
<CardContent className="space-y-3">
|
|
180
|
+
<div className="flex justify-between items-center">
|
|
181
|
+
<div className="flex items-center gap-2 text-sm"><MemoryStick className="h-4 w-4 text-muted-foreground" />堆内存使用</div>
|
|
182
|
+
<Badge variant="secondary">{stats ? `${stats.memory.toFixed(2)} MB` : '-'}</Badge>
|
|
183
|
+
</div>
|
|
184
|
+
<div className="flex justify-between items-center">
|
|
185
|
+
<div className="flex items-center gap-2 text-sm"><MemoryStick className="h-4 w-4 text-muted-foreground" />总堆内存</div>
|
|
186
|
+
<Badge variant="secondary">{systemStatus ? formatMemory(systemStatus.memory.heapTotal) : '-'}</Badge>
|
|
187
|
+
</div>
|
|
188
|
+
<div className="flex justify-between items-center">
|
|
189
|
+
<div className="flex items-center gap-2 text-sm"><MemoryStick className="h-4 w-4 text-muted-foreground" />RSS</div>
|
|
190
|
+
<Badge variant="secondary">{systemStatus ? formatMemory(systemStatus.memory.rss) : '-'}</Badge>
|
|
191
|
+
</div>
|
|
192
|
+
</CardContent>
|
|
249
193
|
</Card>
|
|
250
|
-
</
|
|
194
|
+
</div>
|
|
251
195
|
|
|
252
|
-
{/*
|
|
196
|
+
{/* Quick actions */}
|
|
253
197
|
<Card>
|
|
254
|
-
<
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
<Flex direction="column" align="start" gap="2" style={{ width: '100%' }}>
|
|
267
|
-
<Package size={20} color="var(--blue-9)" />
|
|
268
|
-
<Text weight="medium">插件管理</Text>
|
|
269
|
-
<Text size="1" color="gray">查看和管理插件</Text>
|
|
270
|
-
</Flex>
|
|
198
|
+
<CardHeader>
|
|
199
|
+
<CardTitle>快速操作</CardTitle>
|
|
200
|
+
<CardDescription>常用功能快捷入口</CardDescription>
|
|
201
|
+
</CardHeader>
|
|
202
|
+
<CardContent>
|
|
203
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
|
204
|
+
<Button variant="outline" className="h-auto p-4 justify-start" onClick={() => navigate('/plugins')}>
|
|
205
|
+
<div className="flex flex-col items-start gap-1">
|
|
206
|
+
<Package className="h-5 w-5 mb-1" />
|
|
207
|
+
<span className="font-medium">插件管理</span>
|
|
208
|
+
<span className="text-xs text-muted-foreground">查看和管理插件</span>
|
|
209
|
+
</div>
|
|
271
210
|
</Button>
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<Flex direction="column" align="start" gap="2" style={{ width: '100%' }}>
|
|
279
|
-
<Bot size={20} color="var(--green-9)" />
|
|
280
|
-
<Text weight="medium">机器人状态</Text>
|
|
281
|
-
<Text size="1" color="gray">监控机器人运行</Text>
|
|
282
|
-
</Flex>
|
|
211
|
+
<Button variant="outline" className="h-auto p-4 justify-start" onClick={() => navigate('/bots')}>
|
|
212
|
+
<div className="flex flex-col items-start gap-1">
|
|
213
|
+
<Bot className="h-5 w-5 mb-1" />
|
|
214
|
+
<span className="font-medium">机器人状态</span>
|
|
215
|
+
<span className="text-xs text-muted-foreground">监控机器人运行</span>
|
|
216
|
+
</div>
|
|
283
217
|
</Button>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
<Flex direction="column" align="start" gap="2" style={{ width: '100%' }}>
|
|
291
|
-
<FileText size={20} color="var(--purple-9)" />
|
|
292
|
-
<Text weight="medium">系统日志</Text>
|
|
293
|
-
<Text size="1" color="gray">查看运行日志</Text>
|
|
294
|
-
</Flex>
|
|
218
|
+
<Button variant="outline" className="h-auto p-4 justify-start" onClick={() => navigate('/logs')}>
|
|
219
|
+
<div className="flex flex-col items-start gap-1">
|
|
220
|
+
<FileText className="h-5 w-5 mb-1" />
|
|
221
|
+
<span className="font-medium">系统日志</span>
|
|
222
|
+
<span className="text-xs text-muted-foreground">查看运行日志</span>
|
|
223
|
+
</div>
|
|
295
224
|
</Button>
|
|
296
|
-
</
|
|
297
|
-
</
|
|
225
|
+
</div>
|
|
226
|
+
</CardContent>
|
|
298
227
|
</Card>
|
|
299
|
-
</
|
|
228
|
+
</div>
|
|
300
229
|
)
|
|
301
230
|
}
|