fix(ServerList): refreshInterval

This commit is contained in:
hamster1963 2024-12-11 21:55:55 +08:00
parent 7a31071c3d
commit f28f559a0b
3 changed files with 6 additions and 7 deletions

View File

@ -2,7 +2,7 @@
import { ServerApi } from "@/app/types/nezha-api";
import { nezhaFetcher } from "@/lib/utils";
import useSWR from "swr";
import useSWRImmutable from "swr/immutable";
import { geoJsonString } from "../../../lib/geo-json-string";
import GlobalInfo from "./GlobalInfo";
@ -11,7 +11,7 @@ import { InteractiveMap } from "./InteractiveMap";
import { TooltipProvider } from "./TooltipContext";
export default function ServerGlobal() {
const { data: nezhaServerList, error } = useSWR<ServerApi>(
const { data: nezhaServerList, error } = useSWRImmutable<ServerApi>(
"/api/server",
nezhaFetcher,
);

View File

@ -75,6 +75,7 @@ export default function ServerListClient() {
const { data, error } = useSWR<ServerApi>("/api/server", nezhaFetcher, {
refreshInterval: Number(getEnv("NEXT_PUBLIC_NezhaFetchInterval")) || 2000,
dedupingInterval: 1000,
});
if (error)

View File

@ -14,18 +14,16 @@ import {
} from "@heroicons/react/20/solid";
import { useTranslations } from "next-intl";
import Image from "next/image";
import useSWR from "swr";
import useSWRImmutable from "swr/immutable";
export default function ServerOverviewClient() {
const { status, setStatus } = useStatus();
const { filter, setFilter } = useFilter();
const t = useTranslations("ServerOverviewClient");
const { data, error, isLoading } = useSWR<ServerApi>(
const { data, error, isLoading } = useSWRImmutable<ServerApi>(
"/api/server",
nezhaFetcher,
{
refreshInterval: Number(getEnv("NEXT_PUBLIC_NezhaFetchInterval")) || 2000,
},
);
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";