From c20740a152729342b71cd6f771ce4930a1c1c9ea Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Fri, 25 Oct 2024 01:16:59 +0800 Subject: [PATCH 1/4] feat: add header links --- .env.example | 1 + app/(main)/header.tsx | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/.env.example b/.env.example index b46311b..71b4bec 100644 --- a/.env.example +++ b/.env.example @@ -11,3 +11,4 @@ NEXT_PUBLIC_ForceUseSvgFlag=false NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png NEXT_PUBLIC_CustomTitle=NezhaDash NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha. +NEXT_PUBLIC_Links=[{"link":"https://baidu.com","name":"Baidu"},{"link":"https://google.com","name":"Google"}] diff --git a/app/(main)/header.tsx b/app/(main)/header.tsx index 015a4dc..3f6f543 100644 --- a/app/(main)/header.tsx +++ b/app/(main)/header.tsx @@ -51,6 +51,7 @@ function Header() {

+
@@ -60,6 +61,46 @@ function Header() { ); } +type links = { + link: string; + name: string; +}; + +function Links() { + const linksEnv = getEnv("NEXT_PUBLIC_Links"); + + const links: links[] | null = linksEnv + ? JSON.parse(linksEnv) + : null; + + console.log(links); + + if (!links) return null; + + return ( +
+ {links.map((link, index) => { + return ( + + {link.name} + + ) + })} +
+ ) + + + +} + + + // https://github.com/streamich/react-use/blob/master/src/useInterval.ts const useInterval = (callback: Function, delay?: number | null) => { const savedCallback = useRef(() => { }); From 32f5c09d8be5c4c17f5d01334e8f3aa98da219a2 Mon Sep 17 00:00:00 2001 From: kattocloud <121779192+kattocloud@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:25:17 +0800 Subject: [PATCH 2/4] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f6cbeb1..8793528 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ | NEXT_PUBLIC_CustomLogo | 自定义Logo | **示例**:https://nezha-cf.buycoffee.top/apple-touch-icon.png | | NEXT_PUBLIC_CustomTitle | 自定义标题 | | | NEXT_PUBLIC_CustomDescription | 自定义描述(无多语言支持) | | +| NEXT_PUBLIC_Links | 超级链接| [{"link":"https://baidu.com","name":"Baidu"},{"link":"https://google.com","name":"Google"}] | ![screen](/.github/shot-1.png) ![screen](/.github/shot-2.png) @@ -35,3 +36,4 @@ ![screen](/.github/shot-1-dark.png) ![screen](/.github/shot-2-dark.png) ![screen](/.github/shot-3-dark.png) +![image](https://github.com/user-attachments/assets/cf1a3e74-36fd-4266-94c7-705a74630ed4) From aae30a329408270a29fd5865eea9f19ce7f32fcf Mon Sep 17 00:00:00 2001 From: kattocloud <121779192+kattocloud@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:48:27 +0800 Subject: [PATCH 3/4] Update README.md --- README.md | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 632a85b..9ba6256 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ | 一键部署到 Vercel-推荐 | Docker部署 | Cloudflare部署 | 如何更新? | | ----------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------- | --------------------------------------------------------- | | [部署简易教程](https://buycoffee.top/blog/tech/nezha) | [Docker 部署教程](https://buycoffee.top/blog/tech/nezha-docker) | [Cloudflare 部署教程](https://buycoffee.top/blog/tech/nezha-cloudflare) | [更新教程](https://buycoffee.top/blog/tech/nezha-upgrade) | -| [Vercel-demo](https://nezha-vercel.buycoffee.top) | [Docker-demo](https://nezha-docker.buycoffee.tech) | [Cloudflare-demo](https://nezha-cloudflare.buycoffee.tech) [密码: nezhadash] | #### Cloudflare 部署所需环境变量 @@ -18,23 +17,23 @@ BUN_VERSION 1.1.29 #### 环境变量 -| 变量名 | 含义 | 示例 | -| ------------------------------ | ------------------------ | ------------------------------------------------------------- | -| NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 | -| NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi | -| SitePassword | 页面密码 | **默认**:无密码 | -| DefaultLocale | 面板默认显示语言 | **默认**:en [简中:zh 繁中:zh-t 英语:en 日语:ja] | -| ForceShowAllServers | 是否强制显示所有服务器 | **默认**:false | -| NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**:2000 | -| NEXT_PUBLIC_ShowFlag | 是否显示旗帜 | **默认**:false | -| NEXT_PUBLIC_DisableCartoon | 是否禁用卡通人物 | **默认**:false | -| NEXT_PUBLIC_ShowTag | 是否显示标签 | **默认**:false | -| NEXT_PUBLIC_ShowNetTransfer | 是否显示流量信息 | **默认**:false | -| NEXT_PUBLIC_ForceUseSvgFlag | 是否强制使用SVG旗帜 | **默认**:false | -| NEXT_PUBLIC_CustomLogo | 自定义Logo | **示例**:https://nezha-cf.buycoffee.top/apple-touch-icon.png | -| NEXT_PUBLIC_CustomTitle | 自定义标题 | | -| NEXT_PUBLIC_CustomDescription | 自定义描述(无多语言支持) | | -| NEXT_PUBLIC_Links | 超级链接| [{"link":"https://baidu.com","name":"Baidu"},{"link":"https://google.com","name":"Google"}] | +| 变量名 | 含义 | 示例 | +| ------------------------------ | ------------------------------ | ------------------------------------------------------------- | +| NezhaBaseUrl | nezha 面板地址 | http://120.x.x.x:8008 | +| NezhaAuth | nezha 面板 API Token | 5hAY3QX6Nl9B3Uxxxx26KMvOMyXS1Udi | +| SitePassword | 页面密码 | **默认**:无密码 | +| DefaultLocale | 面板默认显示语言 | **默认**:en [简中:zh 繁中:zh-t 英语:en 日语:ja] | +| ForceShowAllServers | 是否强制显示所有服务器 | **默认**:false | +| NEXT_PUBLIC_NezhaFetchInterval | 获取数据间隔(毫秒) | **默认**:2000 | +| NEXT_PUBLIC_ShowFlag | 是否显示旗帜 | **默认**:false | +| NEXT_PUBLIC_DisableCartoon | 是否禁用卡通人物 | **默认**:false | +| NEXT_PUBLIC_ShowTag | 是否显示标签 | **默认**:false | +| NEXT_PUBLIC_ShowNetTransfer | 是否显示流量信息 | **默认**:false | +| NEXT_PUBLIC_ForceUseSvgFlag | 是否强制使用SVG旗帜 | **默认**:false | +| NEXT_PUBLIC_FixedTopServerName | 是否固定卡片顶部显示服务器名称 | **默认**:false | +| NEXT_PUBLIC_CustomLogo | 自定义Logo | **示例**:https://nezha-cf.buycoffee.top/apple-touch-icon.png | +| NEXT_PUBLIC_CustomTitle | 自定义标题 | | +| NEXT_PUBLIC_CustomDescription | 自定义描述(无多语言支持) | | ![screen](/.github/shot-1.png) ![screen](/.github/shot-2.png) @@ -42,4 +41,3 @@ BUN_VERSION 1.1.29 ![screen](/.github/shot-1-dark.png) ![screen](/.github/shot-2-dark.png) ![screen](/.github/shot-3-dark.png) -![image](https://github.com/user-attachments/assets/cf1a3e74-36fd-4266-94c7-705a74630ed4) From 095c9ed114e439400fdb6914450b0daa49463225 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Fri, 15 Nov 2024 11:21:02 +0800 Subject: [PATCH 4/4] fix(router): error in the back button after refreshing the first time you enter the detail page --- app/(main)/ClientComponents/ServerDetailClient.tsx | 5 +---- app/(main)/header.tsx | 13 +++---------- components/ServerCard.tsx | 6 +++++- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/(main)/ClientComponents/ServerDetailClient.tsx b/app/(main)/ClientComponents/ServerDetailClient.tsx index 98b329a..006e821 100644 --- a/app/(main)/ClientComponents/ServerDetailClient.tsx +++ b/app/(main)/ClientComponents/ServerDetailClient.tsx @@ -29,12 +29,9 @@ export default function ServerDetailClient({ }, []); useEffect(() => { - const previousPath = sessionStorage.getItem("lastPath"); + const previousPath = sessionStorage.getItem("fromMainPage"); if (previousPath) { setHasHistory(true); - } else { - const currentPath = window.location.pathname; - sessionStorage.setItem("lastPath", currentPath); } }, []); diff --git a/app/(main)/header.tsx b/app/(main)/header.tsx index 5da1daf..989c30d 100644 --- a/app/(main)/header.tsx +++ b/app/(main)/header.tsx @@ -69,9 +69,7 @@ type links = { function Links() { const linksEnv = getEnv("NEXT_PUBLIC_Links"); - const links: links[] | null = linksEnv - ? JSON.parse(linksEnv) - : null; + const links: links[] | null = linksEnv ? JSON.parse(linksEnv) : null; console.log(links); @@ -90,17 +88,12 @@ function Links() { > {link.name} - ) + ); })} - ) - - - + ); } - - // https://github.com/streamich/react-use/blob/master/src/useInterval.ts const useInterval = (callback: () => void, delay: number | null) => { const savedCallback = useRef<() => void>(() => {}); diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index 28e4536..1795a1e 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -29,8 +29,12 @@ export default function ServerCard({ const fixedTopServerName = getEnv("NEXT_PUBLIC_FixedTopServerName") === "true"; + const saveSession = () => { + sessionStorage.setItem("fromMainPage", "true"); + }; + return online ? ( - +