Skip to content

Commit

Permalink
fix: empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Nov 23, 2024
1 parent fb38b0e commit f246328
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/pages/Server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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">
Expand Down

0 comments on commit f246328

Please sign in to comment.