import { AlertCircle,Bot,CalendarClock,Check,Clock,Edit2,Loader2,MessageCircle,Power,QrCode,RefreshCw,Sparkles,Trash2,User } from 'lucide-react'; import React from 'react'; import type { AccountDetail } from '../api'; import { accountRuntimePresentation } from '../runtime'; // AccountCardProps 描述账号卡片展示所需的数据和动作。 export interface AccountCardProps { // account 是当前账号的非敏感展示数据。 account: AccountDetail; // refreshing 表示当前账号是否正在刷新资料。 refreshing: boolean; // deleting 表示当前账号是否正在删除。 deleting: boolean; // onRefreshProfile 刷新账号昵称和头像。 onRefreshProfile: (account: AccountDetail) => void | Promise; // onReauthorize 启动当前账号二维码重新授权。 onReauthorize: (account: AccountDetail) => void | Promise; // onEdit 打开账号编辑弹窗。 onEdit: (account: AccountDetail) => void | Promise; // onAI 打开账号 AI 设置弹窗。 onAI: (account: AccountDetail) => void | Promise; // onTasks 打开账号自动化任务弹窗。 onTasks: (account: AccountDetail) => void; // onToggle 切换账号启用状态。 onToggle: (id: string, currentStatus: boolean) => void | Promise; // onDelete 打开账号删除确认框。 onDelete: (account: AccountDetail) => void; } // AccountCard 渲染单个账号的状态摘要与操作入口。 export const AccountCard = React.memo(/* AccountCard 负责渲染单个账号卡片及其操作。 */ function AccountCard({ account, refreshing, deleting, onRefreshProfile, onReauthorize, onEdit, onAI, onTasks, onToggle, onDelete, }: AccountCardProps) { // runtime 保存账号运行状态的展示样式。 const runtime = accountRuntimePresentation(account); // requiresLogin 表示当前账号是否需要重新授权。 const requiresLogin = account.runtime_state === 'auth_expired' || account.runtime_state === 'verification_required'; return (
{account.avatar_url ? ( {account.nickname ) : (
)}
{account.runtime_state === 'online' && }

{account.nickname || account.remark || `账号 ${account.id.substring(0, 6)}...`}

{runtime.label} {account.ai_enabled && ( AI )} {account.auto_rate_enabled && ( 自动评价 )} {account.auto_polish_enabled && ( 每日擦亮 )} {account.auto_confirm && 自动确认发货} {account.profile_error && ( 资料未同步 )}

{account.remark || '暂无备注'}

ID: {account.id}

{account.runtime_message && account.runtime_state !== 'online' && account.runtime_state !== 'disabled' && (
{account.runtime_message} {requiresLogin && ( )}
)} {account.paused && 暂停处理中}
); });