Skip to content

Commit

Permalink
Merge pull request #24 from hamster1963/disable-server-fetch
Browse files Browse the repository at this point in the history
Add disable server fetch config
  • Loading branch information
hamster1963 authored Sep 25, 2024
2 parents 61202b2 + c5b96d1 commit 624ccc7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
13 changes: 10 additions & 3 deletions app/(main)/page.tsx
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
1 change: 1 addition & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 624ccc7

Please sign in to comment.