'use client'; import { useAuth } from '@/providers/auth-provider'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@repo/ui/components/card'; import { Button } from '@repo/ui/components/button'; import { Badge } from '@repo/ui/components/badge'; import { Separator } from '@repo/ui/components/separator'; import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/avatar'; import { LogOut, User, Mail, Phone, MapPin, Calendar, Globe } from 'lucide-react'; export function UserProfile() { const { user, isAuthenticated, logout, isLoading } = useAuth(); if (isLoading) { return (
); } if (!isAuthenticated || !user) { return ( 未登录 请先登录以查看用户信息 ); } const profile = user.profile; const formatDate = (timestamp?: number) => { if (!timestamp) return '未知'; return new Date(timestamp * 1000).toLocaleString('zh-CN'); }; return (
{profile.name?.charAt(0) || profile.preferred_username?.charAt(0) || 'U'}
{profile.name || profile.preferred_username || '未知用户'} 用户ID: {profile.sub}
{/* 基本信息 */}

基本信息

{profile.given_name && (

{profile.given_name}

)} {profile.family_name && (

{profile.family_name}

)} {profile.nickname && (

{profile.nickname}

)} {profile.gender && (

{profile.gender}

)}
{/* 联系信息 */}

联系信息

{profile.email && (

{profile.email}

{profile.email_verified ? '已验证' : '未验证'}
)} {profile.phone_number && (

{profile.phone_number}

{profile.phone_number_verified ? '已验证' : '未验证'}
)}
{profile.address && ( <>

地址信息

{profile.address.formatted && (

{profile.address.formatted}

)}
{profile.address.country && (

{profile.address.country}

)} {profile.address.region && (

{profile.address.region}

)} {profile.address.locality && (

{profile.address.locality}

)} {profile.address.postal_code && (

{profile.address.postal_code}

)}
)} {/* 其他信息 */}

其他信息

{profile.birthdate && (

{profile.birthdate}

)} {profile.zoneinfo && (

{profile.zoneinfo}

)} {profile.locale && (

{profile.locale}

)} {profile.updated_at && (

{formatDate(profile.updated_at)}

)}
{/* Token 信息 */}

Token 信息

{user.expires_at && (

{new Date(user.expires_at * 1000).toLocaleString('zh-CN')}

)}

{user.token_type}

{user.scope?.split(' ').map((scope) => ( {scope} ))}
); }