@zhin.js/console 1.0.20 → 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 +24 -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,6 +1,10 @@
1
1
  import { useEffect, useState } from 'react'
2
2
  import { Bot, AlertCircle, Wifi, WifiOff, Activity, Package, Zap } from 'lucide-react'
3
- import {Flex,Box,Spinner,Text,Callout,Heading,Badge,Separator,Grid,Card} from '@radix-ui/themes'
3
+ import { Card, CardContent } from '../components/ui/card'
4
+ import { Badge } from '../components/ui/badge'
5
+ import { Alert, AlertDescription } from '../components/ui/alert'
6
+ import { Skeleton } from '../components/ui/skeleton'
7
+ import { Separator } from '../components/ui/separator'
4
8
 
5
9
  interface BotInfo {
6
10
  name: string
@@ -24,14 +28,9 @@ export default function DashboardBots() {
24
28
  try {
25
29
  const res = await fetch('/api/bots', { credentials: 'include' })
26
30
  if (!res.ok) throw new Error('API 请求失败')
27
-
28
31
  const data = await res.json()
29
- if (data.success) {
30
- setBots(data.data)
31
- setError(null)
32
- } else {
33
- throw new Error('数据格式错误')
34
- }
32
+ if (data.success) { setBots(data.data); setError(null) }
33
+ else throw new Error('数据格式错误')
35
34
  } catch (err) {
36
35
  setError((err as Error).message)
37
36
  } finally {
@@ -41,158 +40,113 @@ export default function DashboardBots() {
41
40
 
42
41
  if (loading) {
43
42
  return (
44
- <Flex align="center" justify="center" style={{ height: '100%' }}>
45
- <Box>
46
- <Spinner size="3" />
47
- <Text size="2" color="gray" style={{ marginTop: '8px' }}>加载中...</Text>
48
- </Box>
49
- </Flex>
43
+ <div className="space-y-6">
44
+ <Skeleton className="h-8 w-48" />
45
+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
46
+ {[...Array(3)].map((_, i) => <Skeleton key={i} className="h-48" />)}
47
+ </div>
48
+ </div>
50
49
  )
51
50
  }
52
51
 
53
52
  if (error) {
54
53
  return (
55
- <Flex align="center" justify="center" style={{ height: '100%' }}>
56
- <Callout.Root color="red">
57
- <Callout.Icon>
58
- <AlertCircle />
59
- </Callout.Icon>
60
- <Callout.Text>
61
- 加载失败: {error}
62
- </Callout.Text>
63
- </Callout.Root>
64
- </Flex>
54
+ <div className="flex items-center justify-center h-full">
55
+ <Alert variant="destructive" className="max-w-md">
56
+ <AlertCircle className="h-4 w-4" />
57
+ <AlertDescription>加载失败: {error}</AlertDescription>
58
+ </Alert>
59
+ </div>
65
60
  )
66
61
  }
67
62
 
68
63
  return (
69
- <Box>
70
- {/* 页面标题 */}
71
- <Flex direction="column" gap="2" mb="6">
72
- <Heading size="8">机器人管理</Heading>
73
- <Flex align="center" gap="2">
74
- <Text color="gray">共 {bots.length} 个机器人,</Text>
75
- <Badge color="green">{bots.filter(b => b.connected).length}</Badge>
76
- <Text color="gray">个在线</Text>
77
- </Flex>
78
- </Flex>
79
-
80
- <Separator size="4" mb="6" />
81
-
82
- {/* 机器人列表 */}
83
- <Grid columns={{ initial: '1', sm: '2', lg: '3' }} gap="4">
64
+ <div className="space-y-6">
65
+ {/* Header */}
66
+ <div>
67
+ <h1 className="text-2xl font-bold tracking-tight">机器人管理</h1>
68
+ <div className="flex items-center gap-2 mt-1">
69
+ <span className="text-sm text-muted-foreground">共 {bots.length} 个机器人,</span>
70
+ <Badge variant="success">{bots.filter(b => b.connected).length}</Badge>
71
+ <span className="text-sm text-muted-foreground">个在线</span>
72
+ </div>
73
+ </div>
74
+
75
+ <Separator />
76
+
77
+ {/* Bot grid */}
78
+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
84
79
  {bots.map((bot, index) => (
85
80
  <Card key={`${bot.adapter}-${bot.name}-${index}`}>
86
- <Flex direction="column" gap="3">
87
- {/* 头部 */}
88
- <Flex justify="between" align="center">
89
- <Flex align="center" gap="2">
90
- <Box
91
- style={{
92
- padding: '8px',
93
- borderRadius: '8px',
94
- backgroundColor: bot.connected ? 'var(--green-3)' : 'var(--gray-3)'
95
- }}
96
- >
97
- <Bot
98
- size={20}
99
- color={bot.connected ? 'var(--green-9)' : 'var(--gray-9)'}
100
- />
101
- </Box>
102
- <Text size="4" weight="bold">{bot.name}</Text>
103
- </Flex>
104
-
105
- <Box style={{ position: 'relative' }}>
106
- <Badge color={bot.connected ? 'green' : 'gray'}>
107
- <Flex align="center" gap="1">
108
- {bot.connected ? (
109
- <>
110
- <Wifi size={12} />
111
- 在线
112
- </>
113
- ) : (
114
- <>
115
- <WifiOff size={12} />
116
- 离线
117
- </>
118
- )}
119
- </Flex>
81
+ <CardContent className="p-5 space-y-4">
82
+ {/* Header */}
83
+ <div className="flex justify-between items-center">
84
+ <div className="flex items-center gap-2">
85
+ <div className={`p-2 rounded-md ${bot.connected ? 'bg-emerald-100 dark:bg-emerald-900/30' : 'bg-muted'}`}>
86
+ <Bot className={`w-5 h-5 ${bot.connected ? 'text-emerald-600 dark:text-emerald-400' : 'text-muted-foreground'}`} />
87
+ </div>
88
+ <span className="text-lg font-bold">{bot.name}</span>
89
+ </div>
90
+ <div className="relative">
91
+ <Badge variant={bot.connected ? 'success' : 'secondary'}>
92
+ {bot.connected ? <><Wifi className="w-3 h-3 mr-1" />在线</> : <><WifiOff className="w-3 h-3 mr-1" />离线</>}
120
93
  </Badge>
121
- {bot.connected && (
122
- <Box
123
- style={{
124
- position: 'absolute',
125
- top: '-4px',
126
- right: '-4px',
127
- width: '8px',
128
- height: '8px',
129
- borderRadius: '50%',
130
- backgroundColor: 'var(--green-9)',
131
- animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite'
132
- }}
133
- />
134
- )}
135
- </Box>
136
- </Flex>
94
+ </div>
95
+ </div>
137
96
 
138
- {/* 适配器信息 */}
139
- <Flex align="center" gap="2">
140
- <Text size="2" color="gray">适配器:</Text>
97
+ {/* Adapter */}
98
+ <div className="flex items-center gap-2">
99
+ <span className="text-sm text-muted-foreground">适配器:</span>
141
100
  <Badge variant="outline">{bot.adapter}</Badge>
142
- </Flex>
143
-
144
- <Separator size="4" />
145
-
146
- {/* 详细信息 */}
147
- <Flex direction="column" gap="2">
148
- <Flex justify="between" align="center" p="2" style={{ borderRadius: '6px', backgroundColor: 'var(--gray-2)' }}>
149
- <Flex align="center" gap="2">
150
- <Activity
151
- size={16}
152
- color={bot.status === 'online' ? 'var(--green-9)' : 'var(--gray-9)'}
153
- />
154
- <Text size="2" color="gray">运行状态</Text>
155
- </Flex>
156
- <Badge color={bot.status === 'online' ? 'green' : 'gray'}>
101
+ </div>
102
+
103
+ <Separator />
104
+
105
+ {/* Details */}
106
+ <div className="space-y-2">
107
+ <div className="flex justify-between items-center p-2 rounded-md bg-muted/50">
108
+ <div className="flex items-center gap-2 text-sm">
109
+ <Activity className={`w-4 h-4 ${bot.status === 'online' ? 'text-emerald-500' : 'text-muted-foreground'}`} />
110
+ <span className="text-muted-foreground">运行状态</span>
111
+ </div>
112
+ <Badge variant={bot.status === 'online' ? 'success' : 'secondary'}>
157
113
  {bot.status === 'online' ? '运行中' : '已停止'}
158
114
  </Badge>
159
- </Flex>
160
-
161
- <Flex justify="between" align="center" p="2" style={{ borderRadius: '6px', backgroundColor: 'var(--gray-2)' }}>
162
- <Flex align="center" gap="2">
163
- <Package size={16} color="var(--blue-9)" />
164
- <Text size="2" color="gray">适配器类型</Text>
165
- </Flex>
166
- <Text size="2" weight="medium">{bot.adapter}</Text>
167
- </Flex>
168
-
169
- <Flex justify="between" align="center" p="2" style={{ borderRadius: '6px', backgroundColor: 'var(--gray-2)' }}>
170
- <Flex align="center" gap="2">
171
- <Zap size={16} color="var(--purple-9)" />
172
- <Text size="2" color="gray">连接状态</Text>
173
- </Flex>
174
- <Text size="2" weight="medium" color={bot.connected ? 'green' : 'gray'}>
115
+ </div>
116
+ <div className="flex justify-between items-center p-2 rounded-md bg-muted/50">
117
+ <div className="flex items-center gap-2 text-sm">
118
+ <Package className="w-4 h-4 text-muted-foreground" />
119
+ <span className="text-muted-foreground">适配器类型</span>
120
+ </div>
121
+ <span className="text-sm font-medium">{bot.adapter}</span>
122
+ </div>
123
+ <div className="flex justify-between items-center p-2 rounded-md bg-muted/50">
124
+ <div className="flex items-center gap-2 text-sm">
125
+ <Zap className="w-4 h-4 text-muted-foreground" />
126
+ <span className="text-muted-foreground">连接状态</span>
127
+ </div>
128
+ <span className={`text-sm font-medium ${bot.connected ? 'text-emerald-600 dark:text-emerald-400' : 'text-muted-foreground'}`}>
175
129
  {bot.connected ? '已连接' : '未连接'}
176
- </Text>
177
- </Flex>
178
- </Flex>
179
- </Flex>
130
+ </span>
131
+ </div>
132
+ </div>
133
+ </CardContent>
180
134
  </Card>
181
135
  ))}
182
- </Grid>
136
+ </div>
183
137
 
184
- {/* 空状态 */}
138
+ {/* Empty state */}
185
139
  {bots.length === 0 && (
186
140
  <Card>
187
- <Flex direction="column" align="center" gap="4" py="9">
188
- <Bot size={64} color="var(--gray-6)" />
189
- <Flex direction="column" align="center" gap="2">
190
- <Heading size="4">暂无机器人</Heading>
191
- <Text color="gray">请先配置并启动机器人</Text>
192
- </Flex>
193
- </Flex>
141
+ <CardContent className="flex flex-col items-center gap-4 py-12">
142
+ <Bot className="w-16 h-16 text-muted-foreground/30" />
143
+ <div className="text-center">
144
+ <h3 className="text-lg font-semibold">暂无机器人</h3>
145
+ <p className="text-sm text-muted-foreground">请先配置并启动机器人</p>
146
+ </div>
147
+ </CardContent>
194
148
  </Card>
195
149
  )}
196
- </Box>
150
+ </div>
197
151
  )
198
152
  }