From 45a5d6e0502c1e7aed63ea7894a2cd454af4cc59 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Fri, 2 Aug 2024 11:47:01 +0800 Subject: [PATCH] feat: new fetch interval env --- .env.example | 3 ++- app/(main)/ClientComponents/ServerListClient.tsx | 4 +++- app/(main)/ClientComponents/ServerOverviewClient.tsx | 4 +--- app/(main)/layout.tsx | 2 -- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 735293d..dc0f887 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ NezhaBaseUrl=http://0.0.0.0:8008 -NezhaAuth=5hAY3QX6Nl9B3UOQgB26KdsdS1dsdUdM \ No newline at end of file +NezhaAuth=5hAY3QX6Nl9B3UOQgB26KdsdS1dsdUdM +NEXT_PUBLIC_NezhaFetchInterval=2 \ No newline at end of file diff --git a/app/(main)/ClientComponents/ServerListClient.tsx b/app/(main)/ClientComponents/ServerListClient.tsx index 0d3186b..192885b 100644 --- a/app/(main)/ClientComponents/ServerListClient.tsx +++ b/app/(main)/ClientComponents/ServerListClient.tsx @@ -7,7 +7,9 @@ import useSWR from "swr"; export default function ServerListClient() { const { data } = useSWR("/api/server", nezhaFetcher, { - refreshInterval: 3000, + refreshInterval: process.env.NEXT_PUBLIC_NezhaFetchInterval + ? Number(process.env.NEXT_PUBLIC_NezhaFetchInterval) + : 2000, }); if (!data) return null; const sortedResult = data.result.sort((a, b) => a.id - b.id); diff --git a/app/(main)/ClientComponents/ServerOverviewClient.tsx b/app/(main)/ClientComponents/ServerOverviewClient.tsx index d64c1d5..a919b53 100644 --- a/app/(main)/ClientComponents/ServerOverviewClient.tsx +++ b/app/(main)/ClientComponents/ServerOverviewClient.tsx @@ -9,9 +9,7 @@ import { Loader } from "@/components/loading/Loader"; import { ServerApi } from "@/app/types/nezha-api"; export default function ServerOverviewClient() { - const { data } = useSWR("/api/server", nezhaFetcher, { - refreshInterval: 30000, - }); + const { data } = useSWR("/api/server", nezhaFetcher); return (
diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx index dcb0983..5e163b0 100644 --- a/app/(main)/layout.tsx +++ b/app/(main)/layout.tsx @@ -13,8 +13,6 @@ export default function MainLayout({ children }: DashboardProps) {
- {/* */} - {/*