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] 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(() => { });