feat: new fetch interval env

This commit is contained in:
hamster1963 2024-08-02 11:47:01 +08:00
parent 81ea88443e
commit 45a5d6e050
4 changed files with 6 additions and 7 deletions

View File

@ -1,2 +1,3 @@
NezhaBaseUrl=http://0.0.0.0:8008
NezhaAuth=5hAY3QX6Nl9B3UOQgB26KdsdS1dsdUdM
NezhaAuth=5hAY3QX6Nl9B3UOQgB26KdsdS1dsdUdM
NEXT_PUBLIC_NezhaFetchInterval=2

View File

@ -7,7 +7,9 @@ import useSWR from "swr";
export default function ServerListClient() {
const { data } = useSWR<ServerApi>("/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);

View File

@ -9,9 +9,7 @@ import { Loader } from "@/components/loading/Loader";
import { ServerApi } from "@/app/types/nezha-api";
export default function ServerOverviewClient() {
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher, {
refreshInterval: 30000,
});
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher);
return (
<section className="grid grid-cols-2 gap-4 md:grid-cols-4">

View File

@ -13,8 +13,6 @@ export default function MainLayout({ children }: DashboardProps) {
<div className="flex min-h-screen w-full flex-col">
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:p-10 md:pt-8">
<Header />
{/* <BlurLayers /> */}
{/* <Nav /> */}
{children}
<Footer />
</main>