feat: refine operations UI and transport limits

This commit is contained in:
hectorzhao
2026-08-13 10:42:59 +08:00
parent fb02cbcf39
commit 67fee21616
34 changed files with 314 additions and 188 deletions
+5 -18
View File
@@ -1,12 +1,15 @@
import { useEffect, useMemo, useState } from 'react';
import { Activity } from 'lucide-react';
import { Breadcrumb, Button, Table, Tag, type TableColumn } from '@/components/ui';
import { Breadcrumb, Button, CarrierTag, Table, Tag, type TableColumn } from '@/components/ui';
import { adminApi, type AdminChannel } from '@/api/adminApi';
const columns: Array<TableColumn<AdminChannel>> = [
{ key: 'id', title: '通道编号', render: (record) => record.id },
{ key: 'name', title: '通道名称', render: (record) => record.name },
{ key: 'carrier', title: '运营商', render: (record) => carrierLabel(record.carrier) },
{ key: 'carrier', title: '运营商', render: (record) => {
const carriers = record.carriers?.length ? record.carriers : record.carrier === 'all' ? ['mobile', 'unicom', 'telecom'] : record.carrier ? [record.carrier] : [];
return carriers.length ? <span className="ui-carrier-tags">{carriers.map((carrier) => <CarrierTag carrier={carrier} key={carrier} />)}</span> : '-';
} },
{ key: 'gatewayHost', title: '网关地址', render: (record) => `${record.gatewayHost}:${record.gatewayPort}` },
{ key: 'rateLimitPerSecond', title: '限速', render: (record) => `${record.rateLimitPerSecond} 条/秒` },
{
@@ -16,22 +19,6 @@ const columns: Array<TableColumn<AdminChannel>> = [
},
];
const carrierLabels: Record<string, string> = {
mobile: '移动',
cmcc: '移动',
unicom: '联通',
cucc: '联通',
telecom: '电信',
ctcc: '电信',
all: '三网',
unknown: '未识别',
};
function carrierLabel(value?: string | null) {
if (!value) return '-';
return carrierLabels[value.trim().toLowerCase()] ?? value;
}
export function AdminMonitorPage() {
const [channels, setChannels] = useState<AdminChannel[]>([]);
const [monitor, setMonitor] = useState<Record<string, unknown>>({});