diff --git a/.env.example b/.env.example
index 3b0c291..b452c5f 100644
--- a/.env.example
+++ b/.env.example
@@ -1,3 +1,5 @@
NezhaBaseUrl=http://0.0.0.0:8008
NezhaAuth=5hAY3QX6Nl9B3UOQgB26KdsdS1dsdUdM
NEXT_PUBLIC_NezhaFetchInterval=5000
+NEXT_PUBLIC_ShowFlag=true
+NEXT_PUBLIC_DisableCartoon=true
\ No newline at end of file
diff --git a/README.md b/README.md
index 4bc6488..c88c55a 100644
--- a/README.md
+++ b/README.md
@@ -11,11 +11,14 @@
#### 环境变量
-变量名 | 含义 | 示例
---- | --- | ---
-NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008
-NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi
-NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒)| **默认**:2000
+| 变量名 | 含义 | 示例 |
+| ------------------------------ | -------------------- | -------------------------------- |
+| NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 |
+| NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi |
+| NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**:2000 |
+| NEXT_PUBLIC_ShowFlag | 是否显示旗帜 | **默认**:false |
+| NEXT_PUBLIC_DisableCartoon | 是否禁用卡通人物 | **默认**:false |
+

diff --git a/app/(main)/ClientComponents/ServerOverviewClient.tsx b/app/(main)/ClientComponents/ServerOverviewClient.tsx
index a919b53..cf370c1 100644
--- a/app/(main)/ClientComponents/ServerOverviewClient.tsx
+++ b/app/(main)/ClientComponents/ServerOverviewClient.tsx
@@ -11,6 +11,8 @@ import { ServerApi } from "@/app/types/nezha-api";
export default function ServerOverviewClient() {
const { data } = useSWR("/api/server", nezhaFetcher);
+ const disableCartoon = process.env.NEXT_PUBLIC_DisableCartoon === "true";
+
return (
@@ -86,13 +88,15 @@ export default function ServerOverviewClient() {
)}
-
+ {!disableCartoon && (
+
+ )}
diff --git a/app/(main)/header.tsx b/app/(main)/header.tsx
index d61da36..5ef2cc0 100644
--- a/app/(main)/header.tsx
+++ b/app/(main)/header.tsx
@@ -4,6 +4,7 @@ import React, { useEffect, useRef, useState } from "react";
import Image from "next/image";
import { Separator } from "@/components/ui/separator";
import { DateTime } from "luxon";
+import { ModeToggle } from "@/components/ThemeSwitcher";
function Header() {
return (
@@ -20,7 +21,7 @@ function Header() {
className="relative !m-0 h-6 w-6 border-2 border-white object-cover object-top !p-0 transition duration-500 group-hover:z-30 group-hover:scale-105"
/>
- HomeDash
+ NezhaDash
- {/* */}
+
diff --git a/app/layout.tsx b/app/layout.tsx
index 5ad011a..6554031 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -14,11 +14,11 @@ const fontSans = FontSans({
export const metadata: Metadata = {
manifest: "/manifest.json",
- title: "HomeDash",
+ title: "NezhaDash",
description: "A dashboard for nezha",
appleWebApp: {
capable: true,
- title: "HomeDash",
+ title: "NezhaDash",
statusBarStyle: "black-translucent",
},
};
diff --git a/bun.lockb b/bun.lockb
index 6b1439a..4eee22a 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx
index fe618fc..7674dbe 100644
--- a/components/ServerCard.tsx
+++ b/components/ServerCard.tsx
@@ -6,17 +6,20 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
-import { formatNezhaInfo } from "@/lib/utils";
+import { cn, formatNezhaInfo } from "@/lib/utils";
import ServerCardPopover from "./ServerCardPopover";
+import getUnicodeFlagIcon from "country-flag-icons/unicode";
export default function ServerCard({
serverInfo,
}: {
serverInfo: NezhaAPISafe;
}) {
- const { name, online, cpu, up, down, mem, stg, ...props } =
+ const { name, country_code, online, cpu, up, down, mem, stg, ...props } =
formatNezhaInfo(serverInfo);
+ const showFlag = process.env.NEXT_PUBLIC_ShowFlag === "true";
+
return online ? (
+ {showFlag ? (
+ country_code ? (
+
+ {getUnicodeFlagIcon(country_code)}
+
+ ) : (
+ 🏴☠️
+ )
+ ) : null}
- {name}
+
+ {name}
+
@@ -69,8 +88,24 @@ export default function ServerCard({
+ {showFlag ? (
+ country_code ? (
+
+ {getUnicodeFlagIcon(country_code)}
+
+ ) : (
+ 🏴☠️
+ )
+ ) : null}
- {name}
+
+ {name}
+
diff --git a/components/ThemeSwitcher.tsx b/components/ThemeSwitcher.tsx
new file mode 100644
index 0000000..5830ade
--- /dev/null
+++ b/components/ThemeSwitcher.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import { Moon, Sun } from "lucide-react";
+import { useTheme } from "next-themes";
+import * as React from "react";
+
+import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+
+export function ModeToggle() {
+ const { setTheme } = useTheme();
+
+ return (
+
+
+
+
+
+ setTheme("light")}>
+ Light
+
+ setTheme("dark")}>
+ Dark
+
+ setTheme("system")}>
+ System
+
+
+
+ );
+}
diff --git a/lib/utils.ts b/lib/utils.ts
index 2512031..ed8ba08 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -15,6 +15,7 @@ export function formatNezhaInfo(serverInfo: NezhaAPISafe) {
online: serverInfo.online_status,
mem: (serverInfo.status.MemUsed / serverInfo.host.MemTotal) * 100,
stg: (serverInfo.status.DiskUsed / serverInfo.host.DiskTotal) * 100,
+ country_code: serverInfo.host.CountryCode,
};
}
diff --git a/package.json b/package.json
index c03e08e..f6be22c 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"@typescript-eslint/eslint-plugin": "^7.5.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
+ "country-flag-icons": "^1.5.13",
"eslint-plugin-simple-import-sort": "^12.0.0",
"lucide-react": "^0.414.0",
"luxon": "^3.4.4",