"use client" import Link from "next/link"; import React, {useEffect} from 'react'; import {AlertCircle, CheckCircle2, Clock, CreditCard, LayoutGrid, LogOut, SettingsIcon, XCircle} from "lucide-react"; import {usePathname, useRouter} from "next/navigation"; import useUserStore from "@/store/user"; import useSubscribeStore from "@/store/subscribe"; import {formatSecond} from "@/utils/format"; function Header() { const {status, remainingSeconds} = useSubscribeStore(); // 2. 根据状态获取配置(颜色、图标、文本) const getStatusConfig = () => { switch (status) { case "trial": return { label: `Trial · ${formatSecond(remainingSeconds)}`, className: "border-blue-200 bg-blue-50 text-blue-800 hover:bg-blue-100", icon: }; case "active": return { label: "Active", className: "border-emerald-200 bg-emerald-50 text-emerald-800 hover:bg-emerald-100", icon: }; case "past_due": return { label: "Payment Due", className: "border-amber-200 bg-amber-50 text-amber-800 hover:bg-amber-100", icon: }; case "canceled": return { label: remainingSeconds > 0 ? `Ends in ${formatSecond(remainingSeconds)}` : "Expired", className: "border-slate-200 bg-slate-50 text-slate-800 hover:bg-slate-100", icon: }; default: return null; // 未加载时不显示 } }; const config = getStatusConfig(); return (
S
StoreAI
{config && ( {config.icon} {config.label} )}
); } /** * 导航栏 */ const NavTabs = () => { const pathname = usePathname(); const tabs = [ {href: "/dashboard", label: "Dashboard", icon: LayoutGrid}, {href: "/dashboard/setting", label: "Settings", icon: SettingsIcon}, {href: "/dashboard/billing", label: "Billing", icon: CreditCard}, ]; return ( ); }; /** * 用户信息 */ const UserMenu = () => { const userStore = useUserStore(); const router = useRouter(); function handleSignOut() { userStore.logout(); router.replace("/login"); } return (
{userStore.user?.email}
Sign out
); }; export default Header