@zhin.js/console 1.0.21 → 1.0.22

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +4 -4
  3. package/client/components.json +17 -0
  4. package/client/index.html +1 -1
  5. package/client/src/components/PluginConfigForm/BasicFieldRenderers.tsx +89 -180
  6. package/client/src/components/PluginConfigForm/CollectionFieldRenderers.tsx +97 -200
  7. package/client/src/components/PluginConfigForm/CompositeFieldRenderers.tsx +31 -70
  8. package/client/src/components/PluginConfigForm/FieldRenderer.tsx +27 -77
  9. package/client/src/components/PluginConfigForm/NestedFieldRenderer.tsx +33 -53
  10. package/client/src/components/PluginConfigForm/index.tsx +71 -173
  11. package/client/src/components/ui/accordion.tsx +54 -0
  12. package/client/src/components/ui/alert.tsx +62 -0
  13. package/client/src/components/ui/avatar.tsx +41 -0
  14. package/client/src/components/ui/badge.tsx +32 -0
  15. package/client/src/components/ui/button.tsx +50 -0
  16. package/client/src/components/ui/card.tsx +50 -0
  17. package/client/src/components/ui/checkbox.tsx +25 -0
  18. package/client/src/components/ui/dialog.tsx +87 -0
  19. package/client/src/components/ui/dropdown-menu.tsx +97 -0
  20. package/client/src/components/ui/input.tsx +21 -0
  21. package/client/src/components/ui/scroll-area.tsx +43 -0
  22. package/client/src/components/ui/select.tsx +127 -0
  23. package/client/src/components/ui/separator.tsx +23 -0
  24. package/client/src/components/ui/skeleton.tsx +12 -0
  25. package/client/src/components/ui/switch.tsx +26 -0
  26. package/client/src/components/ui/tabs.tsx +52 -0
  27. package/client/src/components/ui/textarea.tsx +20 -0
  28. package/client/src/components/ui/tooltip.tsx +27 -0
  29. package/client/src/layouts/dashboard.tsx +91 -221
  30. package/client/src/main.tsx +38 -42
  31. package/client/src/pages/dashboard-bots.tsx +91 -137
  32. package/client/src/pages/dashboard-home.tsx +133 -204
  33. package/client/src/pages/dashboard-logs.tsx +125 -196
  34. package/client/src/pages/dashboard-plugin-detail.tsx +261 -329
  35. package/client/src/pages/dashboard-plugins.tsx +108 -105
  36. package/client/src/style.css +156 -865
  37. package/client/src/theme/index.ts +60 -35
  38. package/client/tailwind.config.js +78 -69
  39. package/dist/client.js +1 -1
  40. package/dist/cva.js +47 -0
  41. package/dist/index.html +1 -1
  42. package/dist/index.js +6 -6
  43. package/dist/react-router.js +7121 -5585
  44. package/dist/react.js +192 -149
  45. package/dist/style.css +2 -2
  46. package/lib/bin.js +2 -2
  47. package/lib/build.js +2 -2
  48. package/lib/index.d.ts +0 -3
  49. package/lib/index.js +160 -205
  50. package/lib/transform.d.ts +26 -0
  51. package/lib/transform.js +78 -0
  52. package/lib/websocket.d.ts +0 -1
  53. package/package.json +8 -7
  54. package/dist/radix-ui-themes.js +0 -9305
  55. package/lib/dev.d.ts +0 -18
  56. 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
- rss: number
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
- <Flex align="center" justify="center" style={{ height: '100%' }}>
82
- <Box>
83
- <Spinner size="3" />
84
- <Text size="2" color="gray" style={{ marginTop: '8px' }}>加载中...</Text>
85
- </Box>
86
- </Flex>
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
- <Flex align="center" justify="center" style={{ height: '100%' }}>
93
- <Callout.Root color="red">
94
- <Callout.Icon>
95
- <AlertCircle />
96
- </Callout.Icon>
97
- <Callout.Text>
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
- <Box>
107
- {/* 页面标题 */}
108
- <Flex direction="column" gap="2" mb="6">
109
- <Heading size="8">系统概览</Heading>
110
- <Text color="gray">实时监控您的机器人框架运行状态</Text>
111
- </Flex>
112
-
113
- {/* 统计卡片 */}
114
- <Grid columns={{ initial: '1', sm: '2', lg: '4' }} gap="4" mb="6">
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
- <Flex direction="column" gap="2">
117
- <Flex justify="between" align="center">
118
- <Text size="2" weight="medium" color="gray">插件总数</Text>
119
- <Box p="2" style={{ borderRadius: '8px', backgroundColor: 'var(--purple-3)' }}>
120
- <Package size={16} color="var(--purple-9)" />
121
- </Box>
122
- </Flex>
123
- <Heading size="7">{stats?.plugins.total || 0}</Heading>
124
- <Flex align="center" gap="1">
125
- <Badge color="blue">{stats?.plugins.active || 0}</Badge>
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
- <Flex direction="column" gap="2">
133
- <Flex justify="between" align="center">
134
- <Text size="2" weight="medium" color="gray">机器人</Text>
135
- <Bot size={16} color="var(--gray-9)" />
136
- </Flex>
137
- <Heading size="7">{stats?.bots.total || 0}</Heading>
138
- <Text size="1" color="green">
139
- {stats?.bots.online || 0} 个在线
140
- </Text>
141
- </Flex>
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
- <Flex direction="column" gap="2">
146
- <Flex justify="between" align="center">
147
- <Text size="2" weight="medium" color="gray">命令数量</Text>
148
- <Activity size={16} color="var(--gray-9)" />
149
- </Flex>
150
- <Heading size="7">{stats?.commands || 0}</Heading>
151
- <Text size="1" color="gray">可用命令</Text>
152
- </Flex>
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
- <Flex direction="column" gap="2">
157
- <Flex justify="between" align="center">
158
- <Text size="2" weight="medium" color="gray">组件数量</Text>
159
- <TrendingUp size={16} color="var(--gray-9)" />
160
- </Flex>
161
- <Heading size="7">{stats?.components || 0}</Heading>
162
- <Text size="1" color="gray">已注册组件</Text>
163
- </Flex>
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
- </Grid>
149
+ </div>
166
150
 
167
- {/* 系统状态 */}
168
- <Grid columns={{ initial: '1', md: '2' }} gap="4" mb="6">
151
+ {/* System status */}
152
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
169
153
  <Card>
170
- <Flex direction="column" gap="4">
171
- <Box>
172
- <Heading size="5" mb="1">系统信息</Heading>
173
- <Text size="2" color="gray">服务器运行状态</Text>
174
- </Box>
175
-
176
- <Flex direction="column" gap="3">
177
- <Flex justify="between" align="center">
178
- <Flex align="center" gap="2">
179
- <Clock size={16} color="var(--gray-9)" />
180
- <Text size="2">运行时间</Text>
181
- </Flex>
182
- <Badge variant="soft">
183
- {systemStatus ? formatUptime(systemStatus.uptime) : '-'}
184
- </Badge>
185
- </Flex>
186
-
187
- <Flex justify="between" align="center">
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
- <Flex direction="column" gap="4">
212
- <Box>
213
- <Heading size="5" mb="1">资源使用</Heading>
214
- <Text size="2" color="gray">内存使用情况</Text>
215
- </Box>
216
-
217
- <Flex direction="column" gap="3">
218
- <Flex justify="between" align="center">
219
- <Flex align="center" gap="2">
220
- <MemoryStick size={16} color="var(--gray-9)" />
221
- <Text size="2">堆内存使用</Text>
222
- </Flex>
223
- <Badge variant="soft">
224
- {stats ? `${stats.memory.toFixed(2)} MB` : '-'}
225
- </Badge>
226
- </Flex>
227
-
228
- <Flex justify="between" align="center">
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
- </Grid>
194
+ </div>
251
195
 
252
- {/* 快速操作 */}
196
+ {/* Quick actions */}
253
197
  <Card>
254
- <Flex direction="column" gap="4">
255
- <Box>
256
- <Heading size="5" mb="1">快速操作</Heading>
257
- <Text size="2" color="gray">常用功能快捷入口</Text>
258
- </Box>
259
-
260
- <Grid columns={{ initial: '1', md: '3' }} gap="3">
261
- <Button
262
- variant="outline"
263
- onClick={() => navigate('/plugins')}
264
- style={{ height: 'auto', padding: '16px', cursor: 'pointer' }}
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
- <Button
274
- variant="outline"
275
- onClick={() => navigate('/bots')}
276
- style={{ height: 'auto', padding: '16px', cursor: 'pointer' }}
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
- <Button
286
- variant="outline"
287
- onClick={() => navigate('/logs')}
288
- style={{ height: 'auto', padding: '16px', cursor: 'pointer' }}
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
- </Grid>
297
- </Flex>
225
+ </div>
226
+ </CardContent>
298
227
  </Card>
299
- </Box>
228
+ </div>
300
229
  )
301
230
  }