From 73bb7b97f10cbf66b23f8a01bb7893fb8294b56b Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Fri, 11 Oct 2024 09:43:03 +0800 Subject: [PATCH] feat: hide for guest --- app/[locale]/types/nezha-api.ts | 1 + lib/serverFetch.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/[locale]/types/nezha-api.ts b/app/[locale]/types/nezha-api.ts index eaca99a..ecfb986 100644 --- a/app/[locale]/types/nezha-api.ts +++ b/app/[locale]/types/nezha-api.ts @@ -17,6 +17,7 @@ export interface NezhaAPI { ipv6: string; valid_ip: string; display_index: number; + hide_for_guest: boolean; host: NezhaAPIHost; status: NezhaAPIStatus; } diff --git a/lib/serverFetch.tsx b/lib/serverFetch.tsx index 22d2451..a3c40f2 100644 --- a/lib/serverFetch.tsx +++ b/lib/serverFetch.tsx @@ -39,8 +39,14 @@ export async function GetNezhaData() { total_bandwidth: 0, result: [], }; + + // remove hidden servers + const nezhaDataFiltered = nezhaData.filter( + (element) => !element.hide_for_guest, + ); + const timestamp = Date.now() / 1000; - data.result = nezhaData.map( + data.result = nezhaDataFiltered.map( (element: MakeOptional) => { if (timestamp - element.last_active > 300) { data.offline_servers += 1;