import { getRequestOrigin } from "@/lib/request-origin"; import { formatLocalDateTime } from "@/lib/datetime"; import { buildNodeHy2Config } from "@/lib/subscription"; import { buildNodeAuthUrl, buildTrafficStatsUrl, listNodes } from "@/lib/store"; import { createNodeAction, deleteNodeAction, updateNodeAction } from "./actions"; function getNodePills(node: { enabled: number; last_error_message: string | null; }) { return [ { label: node.enabled ? "已启用" : "已禁用", className: `status-pill ${node.enabled ? "status-pill--ok" : "status-pill--off"}`, }, node.last_error_message ? { label: "同步异常", className: "status-pill status-pill--danger" } : { label: "同步正常", className: "status-pill status-pill--sage" }, ]; } export default async function NodesPage() { const [nodes, origin] = await Promise.all([listNodes(), getRequestOrigin()]); return (
节点

节点管理

启用 {nodes.filter((node) => node.enabled).length} 总数 {nodes.length}
节点总数 {nodes.length}
启用中 {nodes.filter((node) => node.enabled).length}

新增节点

展开

节点列表

{nodes.length} 个节点
节点 状态 对外地址 trafficStats 在线/流 最近同步 操作
{nodes.map((node) => { const authUrl = buildNodeAuthUrl(node.slug, node.auth_token, origin); const suggestedTrafficStatsUrl = buildTrafficStatsUrl( node.server_host, node.traffic_stats_listen, ); return (
{node.name} /{node.slug} {getNodePills(node).map((pill) => ( {pill.label} ))} {node.server_host}:{node.server_port} hy2 {node.hy2_listen} {node.traffic_stats_url} {node.traffic_stats_listen} {node.last_online_users} / {node.last_stream_count} 用户 / 流 {formatLocalDateTime(node.last_sync_ok_at)} {node.last_error_at ? 错误 {formatLocalDateTime(node.last_error_at)} : null} 编辑
鉴权 URL {authUrl}
自动推导 trafficStats {suggestedTrafficStatsUrl}
查看 hy2 config.yaml
{buildNodeHy2Config(node, origin)}
                    
下载 hy2 config.yaml
{node.last_error_message ? (

{node.last_error_message}

) : null}
); })}
); }