import { Button } from "antd"; import { ArrowUpRight, Coins, LogOut, RefreshCw, Settings, ShieldCheck } from "lucide-react"; import { Link } from "react-router"; import { useWalletBalance } from "@/hooks/use-wallet-balance"; import { useWorkspaceLogout } from "@/hooks/use-workspace-logout"; import { useUserStore } from "@/stores/use-user-store"; import { UserAvatar } from "./user-avatar"; import "./workspace-account-card.css"; /** 同一账户卡片用于顶部和侧栏;余额与退出均复用真实服务。 */ export function WorkspaceAccountCard({ onWallet, onNavigate }: { onWallet: () => void; onNavigate: () => void }) { const user = useUserStore((state) => state.user); const creditsEnabled = useUserStore((state) => state.features.creditsEnabled); const { availableMicrocredits, refreshing, refresh } = useWalletBalance(user?.id, creditsEnabled); const { handleLogout, loggingOut } = useWorkspaceLogout(); if (!user) return null; return
{user.displayName || user.username}@{user.username}
{user.role === "admin" ? "管理员" : "创作者"}
{creditsEnabled ?
可用积分{availableMicrocredits === null ? "—" : (availableMicrocredits / 1_000_000).toLocaleString("zh-CN", { maximumFractionDigits: 2 })}
{availableMicrocredits === null ? : }
: null}
; }