From ed807f6f9156d84eeeda11f88d0002be74b6a0d0 Mon Sep 17 00:00:00 2001 From: dushixiang Date: Sat, 24 Jan 2026 21:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E6=8E=A2=E9=92=88=E7=AE=A1=E7=90=86=E7=9A=84=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=EF=BC=8C=E4=B8=8E=E5=85=AC=E5=85=B1=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4=E7=9A=84=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E9=80=BB=E8=BE=91=20fix=20#47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/portal/pages/ServerList.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/web/src/portal/pages/ServerList.tsx b/web/src/portal/pages/ServerList.tsx index d3db6bd..237bd0b 100644 --- a/web/src/portal/pages/ServerList.tsx +++ b/web/src/portal/pages/ServerList.tsx @@ -82,8 +82,8 @@ const ServerList = () => { const {data: agents = [], isLoading} = useQuery({ queryKey: ['agents', 'online'], queryFn: async () => { - const agents = await listAgents(); - return (agents || []) as AgentWithMetrics[]; + const response = await listAgents(); + return (response.data || []) as AgentWithMetrics[]; }, refetchInterval: 5000, }); @@ -101,7 +101,7 @@ const ServerList = () => { // 计算统计数据 const stats = useMemo(() => { const total = agents.length; - const online = agents.filter(a => a.status === 1).length; + const online = agents?.filter(a => a.status === 1).length; const offline = total - online; // 计算网络统计 @@ -151,11 +151,11 @@ const ServerList = () => { // 过滤逻辑 let displayAgents = agents; if (selectedTag === 'ONLINE') { - displayAgents = agents.filter(a => a.status === 1); + displayAgents = agents?.filter(a => a.status === 1); } else if (selectedTag === 'OFFLINE') { - displayAgents = agents.filter(a => a.status !== 1); + displayAgents = agents?.filter(a => a.status !== 1); } else if (selectedTag && selectedTag !== 'ALL') { - displayAgents = agents.filter(a => a.tags?.map(t => t.toUpperCase()).includes(selectedTag)); + displayAgents = agents?.filter(a => a.tags?.map(t => t.toUpperCase()).includes(selectedTag)); } // debug @@ -205,9 +205,9 @@ const ServerList = () => { const tagKey = tag === 'ALL' ? '' : tag; let count = 0; if (tag === 'ALL') count = agents.length; - else if (tag === 'ONLINE') count = agents.filter(a => a.status === 1).length; - else if (tag === 'OFFLINE') count = agents.filter(a => a.status !== 1).length; - else count = agents.filter(a => a.tags?.map(t => t.toUpperCase()).includes(tag)).length; + else if (tag === 'ONLINE') count = agents?.filter(a => a.status === 1).length; + else if (tag === 'OFFLINE') count = agents?.filter(a => a.status !== 1).length; + else count = agents?.filter(a => a.tags?.map(t => t.toUpperCase()).includes(tag)).length; if (count === 0 && tag !== 'ALL') return null;