"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { History, LogIn, LogOut } from "lucide-react"; import { TaijiIcon } from "@/components/svg/taiji"; import { ModeToggle } from "@/components/mode-toggle"; import { SITE_WIDTH_INNER } from "@/components/layout/site-width"; import { useAuth } from "@/components/auth/auth-provider"; import { Button } from "@/components/ui/button"; const NAV_ITEMS = [ { href: "/learn", label: "易经学习", protected: false }, { href: "/liuyao", label: "六爻算卦", protected: true }, { href: "/bazi", label: "生辰八字", protected: true }, { href: "/combined", label: "综合测算", protected: true }, ] as const; function NavLink({ href, label, needLogin, }: { href: string; label: string; needLogin: boolean; }) { const pathname = usePathname(); const active = href === "/" ? pathname === "/" : pathname === href || pathname.startsWith(`${href}/`); const target = needLogin ? `/login?next=${encodeURIComponent(href)}` : href; return ( {label} ); } export default function Header() { const { authEnabled, loggedIn, username, logout, loading } = useAuth(); return (
知命阁
{!loading && authEnabled && loggedIn && ( )} {!loading && authEnabled && ( loggedIn ? ( ) : ( ) )}
); }