Merge pull request #24 from hamster1963/disable-server-fetch

Add disable server fetch config
This commit is contained in:
仓鼠 2024-09-25 17:45:09 +08:00 committed by GitHub
commit 624ccc75d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,6 @@
NezhaBaseUrl=http://1.1.1.1:8008
NezhaAuth=nezha-token
ServerDisablePrefetch=false
NEXT_PUBLIC_NezhaFetchInterval=2000
NEXT_PUBLIC_ShowFlag=true
NEXT_PUBLIC_DisableCartoon=false

View File

@ -16,6 +16,7 @@
| ------------------------------ | -------------------- | -------------------------------- |
| NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 |
| NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi |
| ServerDisablePrefetch | 是否禁用预加载 | **默认**false |
| NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**2000 |
| NEXT_PUBLIC_ShowFlag | 是否显示旗帜 | **默认**false |
| NEXT_PUBLIC_DisableCartoon | 是否禁用卡通人物 | **默认**false |

View File

@ -1,16 +1,23 @@
import ServerList from "@/components/ServerList";
import ServerOverview from "@/components/ServerOverview";
import getEnv from "@/lib/env-entry";
import { GetNezhaData } from "@/lib/serverFetch";
import { SWRConfig } from "swr";
const disablePrefetch = getEnv("ServerDisablePrefetch") === "true";
const fallback = disablePrefetch
? {}
: {
"/api/server": GetNezhaData(),
};
export default function Home() {
return (
<SWRConfig
value={{
fallback: {
"/api/server": GetNezhaData(),
},
fallback: fallback,
}}
>
<div className="mx-auto grid w-full max-w-5xl gap-4 md:gap-6">

View File

@ -1,5 +1,6 @@
NezhaBaseUrl=http://0.0.0.0:8008
NezhaAuth=5hAY3QX6Nl9B3UOQgB26KdsdS1dsdUdM
ServerDisablePrefetch=false
NEXT_PUBLIC_NezhaFetchInterval=5000
NEXT_PUBLIC_ShowFlag=true
NEXT_PUBLIC_DisableCartoon=true