mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Merge pull request #9 from hamster1963/swr-interval-config
feat: new fetch interval env
This commit is contained in:
commit
a010a5b962
@ -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
|
@ -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);
|
||||||
|
@ -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">
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user