From badf4258b1a356a261adebda7a7a1947586b8d87 Mon Sep 17 00:00:00 2001 From: WangDL Date: Sat, 23 May 2026 09:39:53 +0800 Subject: [PATCH] feat: M0-08 AI Gateway admin web page --- src/App.tsx | 4 +++ src/config/menu.tsx | 1 + src/layouts/AdminLayout.tsx | 1 + src/pages/AiGateway.tsx | 57 +++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 src/pages/AiGateway.tsx diff --git a/src/App.tsx b/src/App.tsx index 8265ab1..0d7c235 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -107,6 +107,10 @@ function App() { path="config" element={}>} /> + }>} + /> }>} diff --git a/src/config/menu.tsx b/src/config/menu.tsx index 4f00b27..9e16572 100644 --- a/src/config/menu.tsx +++ b/src/config/menu.tsx @@ -31,6 +31,7 @@ export const adminMenuItems: AdminMenuItem[] = [ { path: '/git', name: '代码仓库', icon: }, { path: '/ops', name: '系统运维', icon: , requiredRole: 'SUPER_ADMIN', children: [ { path: '/metrics', name: '接口监控' }, + { path: '/ai-gateway', name: 'AI Gateway' }, { path: '/servers', name: '服务器' }, { path: '/events', name: '事件队列' }, { path: '/config', name: '配置管理' }, diff --git a/src/layouts/AdminLayout.tsx b/src/layouts/AdminLayout.tsx index a9ec455..f9fd636 100644 --- a/src/layouts/AdminLayout.tsx +++ b/src/layouts/AdminLayout.tsx @@ -26,6 +26,7 @@ const breadcrumbMap: Record = { '/servers': '服务器运维', '/config': '配置管理', '/metrics': '接口监控', + '/ai-gateway': 'AI Gateway', '/safety': '内容安全', '/events': '事件队列', '/audit': '审计日志', diff --git a/src/pages/AiGateway.tsx b/src/pages/AiGateway.tsx new file mode 100644 index 0000000..f623e48 --- /dev/null +++ b/src/pages/AiGateway.tsx @@ -0,0 +1,57 @@ +import { useQuery, useQueryClient } from '@tanstack/react-query' +import { Card, Row, Col, Statistic, Table, Tag, Button, Typography } from 'antd' +import { ReloadOutlined, CloudOutlined } from '@ant-design/icons' +import { api } from '@/services/http-client' + +const { Title, Text } = Typography + +export default function AiGatewayPage() { + const qc = useQueryClient() + const { data } = useQuery({ queryKey: ['ai-gateway', 'status'], queryFn: (): Promise => api.get('/admin-api/ai-gateway/status'), staleTime: 30_000 }) + + const tierCols = [ + { title: '级别', dataIndex: 'name', width: 80 }, + { title: '主模型', dataIndex: 'provider', width: 120 }, + { title: '模型', dataIndex: 'model', width: 180 }, + { title: '备用', dataIndex: 'fallback', width: 180, render: (v: string) => v || '-' }, + ] + + const tiers = data?.tiers ? [ + { name: 'cheap', ...data.tiers.cheap, fallback: data.tiers.cheap.fallback?.model || '-' }, + { name: 'primary', ...data.tiers.primary, fallback: data.tiers.primary.fallback?.model || data.tiers.primary.fallback || '-' }, + { name: 'strong', ...data.tiers.strong, fallback: data.tiers.strong.fallback?.model || '-' }, + ] : [] + + return ( +
+
+ <CloudOutlined /> AI Gateway + +
+ + + + + + + + + + + + ({ name: p }))} columns={[{ title: '名称', dataIndex: 'name', render: (v: string) => {v} }]} rowKey="name" pagination={false} size="small" /> + + + + +
+ + + + + +
({ name: p }))} columns={[{ title: '名称', dataIndex: 'name', render: (v: string) => {v} }]} rowKey="name" pagination={false} size="small" /> + + + ) +}