diff --git a/.env.example b/.env.example index 1d155b4..a0c04ed 100644 --- a/.env.example +++ b/.env.example @@ -12,4 +12,5 @@ NEXT_PUBLIC_FixedTopServerName=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"}] NEXT_PUBLIC_DisableIndex=false 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 d1dc802..989c30d 100644 --- a/app/(main)/header.tsx +++ b/app/(main)/header.tsx @@ -51,6 +51,7 @@ function Header() {

+
@@ -60,6 +61,39 @@ 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: () => 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 ? ( - +