mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 09:31:55 +08:00
fix: empty data
This commit is contained in:
parent
fb38b0eb8a
commit
f24632826c
@ -58,24 +58,24 @@ export default function Servers() {
|
||||
}
|
||||
|
||||
// 计算所有服务器的统计数据(用于 Overview)
|
||||
const totalServers = nezhaWsData.servers.length;
|
||||
const onlineServers = nezhaWsData.servers.filter(
|
||||
const totalServers = nezhaWsData?.servers?.length || 0;
|
||||
const onlineServers = nezhaWsData?.servers?.filter(
|
||||
(server) => formatNezhaInfo(server).online,
|
||||
).length;
|
||||
const offlineServers = nezhaWsData.servers.filter(
|
||||
)?.length || 0;
|
||||
const offlineServers = nezhaWsData?.servers?.filter(
|
||||
(server) => !formatNezhaInfo(server).online,
|
||||
).length;
|
||||
const up = nezhaWsData.servers.reduce(
|
||||
)?.length || 0;
|
||||
const up = nezhaWsData?.servers?.reduce(
|
||||
(total, server) => total + server.state.net_out_transfer,
|
||||
0,
|
||||
);
|
||||
const down = nezhaWsData.servers.reduce(
|
||||
) || 0;
|
||||
const down = nezhaWsData?.servers?.reduce(
|
||||
(total, server) => total + server.state.net_in_transfer,
|
||||
0,
|
||||
);
|
||||
) || 0;
|
||||
|
||||
// 根据当前选中的分组筛选服务器(用于显示列表)
|
||||
const filteredServers = nezhaWsData.servers.filter((server) => {
|
||||
const filteredServers = nezhaWsData?.servers?.filter((server) => {
|
||||
if (currentGroup === "All") return true;
|
||||
const group = groupData?.data?.find(
|
||||
(g: ServerGroup) =>
|
||||
@ -84,7 +84,7 @@ export default function Servers() {
|
||||
g.servers.includes(server.id),
|
||||
);
|
||||
return !!group;
|
||||
});
|
||||
}) || [];
|
||||
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-5xl px-0">
|
||||
|
Loading…
x
Reference in New Issue
Block a user