@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.
- package/CHANGELOG.md +24 -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 +8 -7
- package/dist/radix-ui-themes.js +0 -9305
- package/lib/dev.d.ts +0 -18
- 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 {
|
|
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
|
-
|
|
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
|
-
<
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
</
|
|
49
|
-
</
|
|
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
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
<
|
|
70
|
-
{/*
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<Badge
|
|
76
|
-
<
|
|
77
|
-
</
|
|
78
|
-
</
|
|
79
|
-
|
|
80
|
-
<Separator
|
|
81
|
-
|
|
82
|
-
{/*
|
|
83
|
-
<
|
|
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
|
-
<
|
|
87
|
-
{/*
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
>
|
|
97
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
<
|
|
140
|
-
<
|
|
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
|
-
</
|
|
143
|
-
|
|
144
|
-
<Separator
|
|
145
|
-
|
|
146
|
-
{/*
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
<
|
|
150
|
-
<Activity
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
</
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
</
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
</
|
|
177
|
-
</
|
|
178
|
-
</
|
|
179
|
-
</
|
|
130
|
+
</span>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
</CardContent>
|
|
180
134
|
</Card>
|
|
181
135
|
))}
|
|
182
|
-
</
|
|
136
|
+
</div>
|
|
183
137
|
|
|
184
|
-
{/*
|
|
138
|
+
{/* Empty state */}
|
|
185
139
|
{bots.length === 0 && (
|
|
186
140
|
<Card>
|
|
187
|
-
<
|
|
188
|
-
<Bot
|
|
189
|
-
<
|
|
190
|
-
<
|
|
191
|
-
<
|
|
192
|
-
</
|
|
193
|
-
</
|
|
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
|
-
</
|
|
150
|
+
</div>
|
|
197
151
|
)
|
|
198
152
|
}
|