Merge pull request #9 from hamster1963/swr-interval-config

feat: new fetch interval env
This commit is contained in:
仓鼠 2024-08-02 11:49:48 +08:00 committed by GitHub
commit a010a5b962
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 7 deletions

View File

@ -1,2 +1,3 @@
NezhaBaseUrl=http://0.0.0.0:8008 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() { export default function ServerListClient() {
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher, { 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; if (!data) return null;
const sortedResult = data.result.sort((a, b) => a.id - b.id); 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"; import { ServerApi } from "@/app/types/nezha-api";
export default function ServerOverviewClient() { export default function ServerOverviewClient() {
const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher, { const { data } = useSWR<ServerApi>("/api/server", nezhaFetcher);
refreshInterval: 30000,
});
return ( return (
<section className="grid grid-cols-2 gap-4 md:grid-cols-4"> <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"> <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"> <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 /> <Header />
{/* <BlurLayers /> */}
{/* <Nav /> */}
{children} {children}
<Footer /> <Footer />
</main> </main>