"use client"; import { useMemo } from "react"; import { signOut } from "next-auth/react"; import toast from "react-hot-toast"; import UserHeader from "@/components/me/UserHeader"; import QuotaCard from "@/components/me/QuotaCard"; import StatsGrid from "@/components/me/StatsGrid"; import MyFanSupport from "@/components/me/MyFanSupport"; import { useVoteStore, selectRemaining, TOTAL_VOTE_QUOTA, type MySupport, } from "@/lib/store"; interface MeContentProps { session: { id: string; nickname: string; }; } export default function MeContent({ session }: MeContentProps) { // 订阅 store 原始引用(稳定,仅在 set() 时变更),组件内 useMemo 派生 supports, // 避免 Zustand v5 + useSyncExternalStore 对"selector 返回新引用"报 infinite-loop 错。 const votedArtists = useVoteStore((s) => s.votedArtists); const storeArtists = useVoteStore((s) => s.artists); const remaining = useVoteStore(selectRemaining); const votedCount = votedArtists.length; const supports = useMemo(() => { const list: MySupport[] = []; for (const id of votedArtists) { const artist = storeArtists.find((a) => a.id === id); if (artist) list.push({ artist }); } return list; }, [votedArtists, storeArtists]); const handleLogout = () => { toast("正在退出登录…"); signOut({ callbackUrl: "/" }); }; return (
); } function SectionTitle({ label }: { label: string }) { return (

{label}

); }