This commit is contained in:
eric
2026-03-31 12:44:54 -05:00
parent 2ffbddff2e
commit 4497604242
10 changed files with 359 additions and 28 deletions

View File

@@ -17,10 +17,19 @@ type VipHeaderProps = {
isLoggedIn: boolean;
userName?: string | null;
userEmail?: string | null;
wechatNick?: string | null;
wechatAvatar?: string | null;
onLogout?: () => void;
};
export function VipHeader({ isLoggedIn, userName, userEmail, onLogout }: VipHeaderProps) {
export function VipHeader({
isLoggedIn,
userName,
userEmail,
wechatNick,
wechatAvatar,
onLogout,
}: VipHeaderProps) {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);
@@ -38,8 +47,9 @@ export function VipHeader({ isLoggedIn, userName, userEmail, onLogout }: VipHead
onLogout?.();
};
const showUser = isLoggedIn || userEmail;
const displayName = userName || userEmail || "会员";
const hasWechatProfile = !!(wechatNick || wechatAvatar);
const showUser = isLoggedIn || !!userEmail || hasWechatProfile;
const displayName = wechatNick || userName || userEmail || "会员";
return (
<header className={styles.header}>
@@ -54,10 +64,15 @@ export function VipHeader({ isLoggedIn, userName, userEmail, onLogout }: VipHead
<button
type="button"
onClick={() => setOpen((o) => !o)}
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-amber-500 text-sm font-semibold text-white shadow-sm hover:bg-amber-600"
className="flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-full bg-amber-500 text-sm font-semibold text-white shadow-sm hover:bg-amber-600"
aria-label="用户菜单"
>
{getAvatarLetter(displayName)}
{wechatAvatar ? (
// eslint-disable-next-line @next/next/no-img-element
<img src={wechatAvatar} alt={displayName} className="h-full w-full object-cover" />
) : (
getAvatarLetter(displayName)
)}
</button>
{isLoggedIn && (
<span