全站汉化 + antd zhCN locale
This commit is contained in:
1 parent
2e4594fa77
commit
b96323eb99
9 files changed
+134
-136
No files matched your search
@@ -23,6 +23,12 @@ interface StrategyInfo {
|
||||
multicast_available: boolean
|
||||
}
|
||||
|
||||
const strategyLabels: Record<string, string> = {
|
||||
'round-robin': '轮询',
|
||||
'weighted': '权重',
|
||||
'least-conn': '最少连接',
|
||||
}
|
||||
|
||||
export default function NodeManager() {
|
||||
const [nodes, setNodes] = useState<NodeInfo[]>([])
|
||||
const [strategy, setStrategy] = useState<StrategyInfo | null>(null)
|
||||
@@ -39,15 +45,15 @@ export default function NodeManager() {
|
||||
])
|
||||
setNodes(nodesRes.data)
|
||||
setStrategy(strategyRes.data)
|
||||
} catch { message.error('Failed to load') }
|
||||
} catch { message.error('加载失败') }
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
async function updateWeight(nodeId: string, weight: number) {
|
||||
try {
|
||||
await api.put(`/nodes/${nodeId}`, { weight })
|
||||
message.success('Updated')
|
||||
} catch { message.error('Failed') }
|
||||
message.success('已更新')
|
||||
} catch { message.error('更新失败') }
|
||||
}
|
||||
|
||||
async function toggleNode(nodeId: string, enabled: boolean) {
|
||||
@@ -56,17 +62,17 @@ export default function NodeManager() {
|
||||
try {
|
||||
await api.put(`/nodes/${nodeId}`, { weight: node.weight, enabled })
|
||||
setNodes((prev) => prev.map((n) => (n.id === nodeId ? { ...n, enabled } : n)))
|
||||
message.success('Updated')
|
||||
} catch { message.error('Failed') }
|
||||
message.success('已更新')
|
||||
} catch { message.error('更新失败') }
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{ title: 'Name', dataIndex: 'name', key: 'name' },
|
||||
{ title: 'Host', dataIndex: 'host', key: 'host' },
|
||||
{ title: 'HLS Port', dataIndex: 'hls_port', key: 'hls_port', width: 100 },
|
||||
{ title: 'API Port', dataIndex: 'api_port', key: 'api_port', width: 100 },
|
||||
{ title: '名称', dataIndex: 'name', key: 'name' },
|
||||
{ title: '主机', dataIndex: 'host', key: 'host' },
|
||||
{ title: 'HLS 端口', dataIndex: 'hls_port', key: 'hls_port', width: 100 },
|
||||
{ title: 'API 端口', dataIndex: 'api_port', key: 'api_port', width: 100 },
|
||||
{
|
||||
title: 'Weight', dataIndex: 'weight', key: 'weight', width: 140,
|
||||
title: '权重', dataIndex: 'weight', key: 'weight', width: 140,
|
||||
render: (_: number, record: NodeInfo) => (
|
||||
<InputNumber
|
||||
min={0}
|
||||
@@ -83,7 +89,7 @@ export default function NodeManager() {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Enabled', dataIndex: 'enabled', key: 'enabled', width: 90,
|
||||
title: '启用', dataIndex: 'enabled', key: 'enabled', width: 80,
|
||||
render: (_: any, record: NodeInfo) => (
|
||||
<Switch
|
||||
checked={record.enabled}
|
||||
@@ -93,42 +99,45 @@ export default function NodeManager() {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Health', key: 'health', width: 100,
|
||||
render: () => <Tag icon={<CheckCircleOutlined />} color="success">Online</Tag>,
|
||||
title: '状态', key: 'health', width: 100,
|
||||
render: () => <Tag icon={<CheckCircleOutlined />} color="success">在线</Tag>,
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Title level={3} style={{ marginBottom: 24 }}>Edge Nodes</Title>
|
||||
<Title level={3} style={{ marginBottom: 24 }}>边缘节点管理</Title>
|
||||
|
||||
{strategy && (
|
||||
<Row gutter={[24, 24]} style={{ marginBottom: 24 }}>
|
||||
<Col xs={24} sm={8}>
|
||||
<Card>
|
||||
<Statistic title="Strategy" value={strategy.strategy} />
|
||||
<Statistic
|
||||
title="负载均衡策略"
|
||||
value={strategyLabels[strategy.strategy] || strategy.strategy}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} sm={8}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="Multicast"
|
||||
value={strategy.multicast_available ? 'Available' : 'Unavailable'}
|
||||
title="组播状态"
|
||||
value={strategy.multicast_available ? '可用' : '不可用'}
|
||||
valueStyle={{ color: strategy.multicast_available ? '#52c41a' : '#999' }}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} sm={8}>
|
||||
<Card>
|
||||
<Statistic title="Edge Nodes" value={nodes.length} />
|
||||
<Statistic title="边缘节点数" value={nodes.length} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
)}
|
||||
|
||||
<Card
|
||||
title="Node List"
|
||||
extra={<Button icon={<ReloadOutlined />} onClick={loadData}>Refresh</Button>}
|
||||
title="节点列表"
|
||||
extra={<Button icon={<ReloadOutlined />} onClick={loadData}>刷新</Button>}
|
||||
>
|
||||
<Table
|
||||
dataSource={nodes}
|
||||
|
||||
Reference in new issue
Block a user