"use client" import * as React from "react" import Link from "next/link" import {motion, useAnimation} from "motion/react" import {useMutation, useQuery, useQueryClient} from "@tanstack/react-query" import {Avatar, AvatarFallback, AvatarImage} from "@/components/ui/avatar" import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@/components/ui/breadcrumb" import {useUser} from "@/contexts/user-context" import {ArrowRight, Link2, Loader2, Shield, Unlink} from "lucide-react" import {Button} from "@/components/ui/button" import {Separator} from "@/components/ui/separator" import {AuthService} from "@/lib/services" import {toast} from "sonner" export function ProfileMain() { const { user, loading, getTrustLevelLabel } = useUser() const controls = useAnimation() const isAnimatingRef = React.useRef(false) const queryClient = useQueryClient() const externalAccountBindingsQuery = useQuery({ queryKey: ["auth", "external-accounts"], queryFn: () => AuthService.getExternalAccountBindings(), }) const publicAuthSourcesQuery = useQuery({ queryKey: ["auth", "public-sources"], queryFn: () => AuthService.getAuthSources(), }) const bindSourceMutation = useMutation({ mutationFn: async (sourceName: string) => { const { authorize_url } = await AuthService.getAuthorizeUrl(sourceName, "bind") sessionStorage.setItem("redirect_after_login", `${window.location.pathname}${window.location.search}`) window.location.href = authorize_url }, onError: (error: Error) => { toast.error(error.message || "绑定认证源失败") }, }) const handleAvatarClick = () => { if (isAnimatingRef.current) return isAnimatingRef.current = true controls.start({ rotate: [0, -20, 20, -20, 20, 0], transition: { duration: 0.5, ease: "easeInOut" } }) setTimeout(() => { isAnimatingRef.current = false }, 650) } if (loading) { return (
您的个人账户基本信息
管理并关联您的第三方授权账户,便于快捷登录与验证