From 134335021dbb9db61d0b6fe5806c9e90247e6af5 Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Mon, 12 May 2025 22:51:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dheader=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tone-page-web/components/Header.tsx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tone-page-web/components/Header.tsx b/tone-page-web/components/Header.tsx index 6c153e7..2fb4e24 100644 --- a/tone-page-web/components/Header.tsx +++ b/tone-page-web/components/Header.tsx @@ -3,7 +3,7 @@ import { cn } from "@/lib/utils"; import Link from "next/link"; import { usePathname } from "next/navigation"; -import { useState } from "react"; +import { useCallback, useState } from "react"; import { Drawer, DrawerContent, @@ -21,11 +21,18 @@ export default function Header() { const [showMenu, setShowMenu] = useState(false); const menuItems = [ - { name: '特恩(TONE)', href: '/' }, - { name: '资源', href: '/resource' }, - { name: '博客', href: '/blog' }, - { name: '控制台', href: '/console/login' }, - ] + { name: '特恩(TONE)', path: '/' }, + { name: '资源', path: '/resource' }, + { name: '博客', path: '/blog' }, + { name: '控制台', path: '/console' }, + ]; + + const getHref = useCallback((path: string) => { + if (path === '/console') { + return localStorage.getItem('token') ? '/console' : '/console/login'; + } + return path; + }, []); return (
@@ -61,11 +68,11 @@ export default function Header() { {menuItems.slice(1).map((item) => ( setShowMenu(false)} > ))} @@ -78,11 +85,11 @@ export default function Header() { )}> {menuItems.slice(1).map((item) => ( {item.name}