mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Merge branch 'main' into cloudflare
This commit is contained in:
commit
fbe12ec57b
@ -1,5 +1,6 @@
|
|||||||
NezhaBaseUrl=http://124.XX.XX.XX:8008
|
NezhaBaseUrl=http://124.XX.XX.XX:8008
|
||||||
NezhaAuth=your-nezha-api-token
|
NezhaAuth=your-nezha-api-token
|
||||||
|
DefaultLocale=zh
|
||||||
NEXT_PUBLIC_NezhaFetchInterval=5000
|
NEXT_PUBLIC_NezhaFetchInterval=5000
|
||||||
NEXT_PUBLIC_ShowFlag=true
|
NEXT_PUBLIC_ShowFlag=true
|
||||||
NEXT_PUBLIC_DisableCartoon=true
|
NEXT_PUBLIC_DisableCartoon=true
|
@ -13,10 +13,10 @@
|
|||||||
#### 环境变量
|
#### 环境变量
|
||||||
|
|
||||||
| 变量名 | 含义 | 示例 |
|
| 变量名 | 含义 | 示例 |
|
||||||
| ------------------------------ | -------------------- | -------------------------------- |
|
| ------------------------------ | -------------------------------- | -------------------------------- |
|
||||||
| NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 |
|
| NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 |
|
||||||
| NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi |
|
| NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi |
|
||||||
| ServerDisablePrefetch | 是否禁用预加载 | **默认**:false |
|
| DefaultLocale | 面板默认显示语言(代码参考下表) | **默认**:en |
|
||||||
| NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**:2000 |
|
| NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**:2000 |
|
||||||
| NEXT_PUBLIC_ShowFlag | 是否显示旗帜 | **默认**:false |
|
| NEXT_PUBLIC_ShowFlag | 是否显示旗帜 | **默认**:false |
|
||||||
| NEXT_PUBLIC_DisableCartoon | 是否禁用卡通人物 | **默认**:false |
|
| NEXT_PUBLIC_DisableCartoon | 是否禁用卡通人物 | **默认**:false |
|
||||||
|
@ -14,11 +14,13 @@ export default function ServerListClient() {
|
|||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center">
|
||||||
<p className="text-sm font-medium opacity-40">{error.message}</p>
|
<p className="text-sm font-medium opacity-40">{error.message}</p>
|
||||||
<p className="text-sm font-medium opacity-40">
|
<p className="text-sm font-medium opacity-40">
|
||||||
Please check your environment variables and review the server console logs for more details.
|
Please check your environment variables and review the server console
|
||||||
|
logs for more details.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
const { result } = data;
|
const { result } = data;
|
||||||
|
|
||||||
const positiveDisplayIndex = result
|
const positiveDisplayIndex = result
|
||||||
@ -38,6 +40,7 @@ export default function ServerListClient() {
|
|||||||
...noDisplayIndex,
|
...noDisplayIndex,
|
||||||
...negativeDisplayIndex,
|
...negativeDisplayIndex,
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="grid grid-cols-1 gap-2 md:grid-cols-2">
|
<section className="grid grid-cols-1 gap-2 md:grid-cols-2">
|
||||||
{sortedServers.map((serverInfo) => (
|
{sortedServers.map((serverInfo) => (
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
NezhaBaseUrl=http://124.XX.XX.XX:8008
|
NezhaBaseUrl=http://124.XX.XX.XX:8008
|
||||||
NezhaAuth=your-nezha-api-token
|
NezhaAuth=your-nezha-api-token
|
||||||
|
DefaultLocale=zh
|
||||||
NEXT_PUBLIC_NezhaFetchInterval=5000
|
NEXT_PUBLIC_NezhaFetchInterval=5000
|
||||||
NEXT_PUBLIC_ShowFlag=true
|
NEXT_PUBLIC_ShowFlag=true
|
||||||
NEXT_PUBLIC_DisableCartoon=true
|
NEXT_PUBLIC_DisableCartoon=true
|
@ -1,5 +1,7 @@
|
|||||||
// @auto-i18n-check. Please do not delete the line.
|
// @auto-i18n-check. Please do not delete the line.
|
||||||
|
|
||||||
|
import getEnv from "./lib/env-entry";
|
||||||
|
|
||||||
export const localeItems = [
|
export const localeItems = [
|
||||||
{ code: "en", name: "English" },
|
{ code: "en", name: "English" },
|
||||||
{ code: "ja", name: "日本語" },
|
{ code: "ja", name: "日本語" },
|
||||||
@ -21,4 +23,4 @@ export const localeItems = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const locales = localeItems.map((item) => item.code);
|
export const locales = localeItems.map((item) => item.code);
|
||||||
export const defaultLocale = "en";
|
export const defaultLocale = getEnv("DefaultLocale") || "en";
|
||||||
|
@ -10,8 +10,8 @@ export async function GetNezhaData() {
|
|||||||
|
|
||||||
var nezhaBaseUrl = getEnv("NezhaBaseUrl");
|
var nezhaBaseUrl = getEnv("NezhaBaseUrl");
|
||||||
if (!nezhaBaseUrl) {
|
if (!nezhaBaseUrl) {
|
||||||
console.error("NezhaBaseUrl is not set");
|
console.log("NezhaBaseUrl is not set");
|
||||||
throw new Error("NezhaBaseUrl is not set");
|
return { error: "NezhaBaseUrl is not set" };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove trailing slash
|
// Remove trailing slash
|
||||||
@ -27,7 +27,12 @@ export async function GetNezhaData() {
|
|||||||
revalidate: 0,
|
revalidate: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const nezhaData = (await response.json()).result as NezhaAPI[];
|
const resData = await response.json();
|
||||||
|
const nezhaData = resData.result as NezhaAPI[];
|
||||||
|
if (!nezhaData) {
|
||||||
|
console.log(resData);
|
||||||
|
return { error: "NezhaData fetch failed" };
|
||||||
|
}
|
||||||
const data: ServerApi = {
|
const data: ServerApi = {
|
||||||
live_servers: 0,
|
live_servers: 0,
|
||||||
offline_servers: 0,
|
offline_servers: 0,
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
// @auto-i18n-check. Please do not delete the line.
|
// @auto-i18n-check. Please do not delete the line.
|
||||||
|
|
||||||
import createMiddleware from "next-intl/middleware";
|
import createMiddleware from "next-intl/middleware";
|
||||||
import { locales } from "./i18n-metadata";
|
import { defaultLocale, locales } from "./i18n-metadata";
|
||||||
|
|
||||||
export default createMiddleware({
|
export default createMiddleware({
|
||||||
// A list of all locales that are supported
|
// A list of all locales that are supported
|
||||||
locales: locales,
|
locales: locales,
|
||||||
|
|
||||||
// Used when no locale matches
|
// Used when no locale matches
|
||||||
defaultLocale: "en",
|
defaultLocale: defaultLocale,
|
||||||
|
|
||||||
// 'always': This is the default, The home page will also be redirected to the default language, such as www.abc.com to www.abc.com/en
|
// 'always': This is the default, The home page will also be redirected to the default language, such as www.abc.com to www.abc.com/en
|
||||||
// 'as-needed': The default page is not redirected. For example, if you open www.abc.com, it is still www.abc.com
|
// 'as-needed': The default page is not redirected. For example, if you open www.abc.com, it is still www.abc.com
|
||||||
|
Loading…
Reference in New Issue
Block a user