import React, { useEffect, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { AccountDetail, AIReplySettings, NotificationChannel } from '../types'; import { getAccountDetails, getAccountRuntimeStatuses, updateAccountStatus, deleteAccount, generateQRLogin, checkQRLoginStatus, completeQRVerification, updateAccountPauseDuration, refreshAccountProfile, updateAccountSettings, passwordLogin, checkPasswordLoginStatus, cancelPasswordLogin, updateAccountAISettings, getAllAISettings, getAccountAISettings, getNotificationChannels, getAccountBindings, getLongLoginSettings, setLongLoginSettings, } from '../services/api'; import { shouldUpdateAccountPause } from './accountPause'; import { Plus, Power, Edit2, Trash2, QrCode, X, Check, Loader2, RefreshCw, Save, User, Clock, MessageCircle, Upload, Key, Eye, EyeOff, Bot, Settings, AlertCircle, Bell } from 'lucide-react'; import { buildAccountLoginInfoUpdate } from './accountEdit'; import { shouldSaveNotificationBindings } from './accountBindings'; import { mergeAccountRuntimeStatuses } from './accountRuntimeState'; import { createLatestRequestGate, createQRLoginPoller } from './qrPolling'; import { RiskVerificationPanel } from './RiskVerificationPanel'; import { SquareQRCode } from './SquareQRCode'; type ModalType = 'edit' | 'ai-settings' | null; const AccountList: React.FC = () => { const [accounts, setAccounts] = useState([]); const [loading, setLoading] = useState(true); const [accountSearch, setAccountSearch] = useState(''); const [refreshingProfileId, setRefreshingProfileId] = useState(''); const [deletingAccountId, setDeletingAccountId] = useState(''); const [deleteDialogAccount, setDeleteDialogAccount] = useState(null); const [deleteError, setDeleteError] = useState(''); const [showQRModal, setShowQRModal] = useState(false); const [qrCodeUrl, setQrCodeUrl] = useState(''); const [qrStatus, setQrStatus] = useState('pending'); const [verificationScreenshot, setVerificationScreenshot] = useState(''); const [faceQrUrl, setFaceQrUrl] = useState(''); const [qrReauthTarget, setQrReauthTarget] = useState(null); const [activeModal, setActiveModal] = useState(null); const [editingAccount, setEditingAccount] = useState(null); const [longLogin, setLongLogin] = useState({ loading: false, saving: false, canOpen: false, enabled: false, error: '' }); // 通知渠道绑定(编辑弹窗用) const [notifChannels, setNotifChannels] = useState([]); const [selectedChannelIds, setSelectedChannelIds] = useState([]); const [bindingsLoaded, setBindingsLoaded] = useState(false); const [bindingsLoading, setBindingsLoading] = useState(false); const [bindingsDirty, setBindingsDirty] = useState(false); const [bindingsLoadError, setBindingsLoadError] = useState(''); // 编辑表单状态 const [editForm, setEditForm] = useState({ remark: '', cookie: '', auto_confirm: false, pause_duration: 0, username: '', login_password: '', show_browser: false, showLoginPassword: false, clear_password: false, }); // AI设置表单状态 const [aiSettings, setAiSettings] = useState({ ai_enabled: false, max_discount_percent: 10, max_discount_amount: 100, max_bargain_rounds: 3, custom_prompts: '', }); const [saving, setSaving] = useState(false); const [passwordLoginView, setPasswordLoginView] = useState<{ sessionId: string; status: 'idle' | 'processing' | 'verification_required' | 'success' | 'failed'; message: string; qrCodeUrl: string; }>({ sessionId: '', status: 'idle', message: '', qrCodeUrl: '' }); const qrPollerRef = useRef | null>(null); const qrRequestGateRef = useRef | null>(null); const accountLoadGateRef = useRef | null>(null); const bindingsLoadGateRef = useRef | null>(null); const aiLoadGateRef = useRef | null>(null); const accountLoadAbortRef = useRef(null); const bindingsLoadAbortRef = useRef(null); const aiLoadAbortRef = useRef(null); const qrGenerateAbortRef = useRef(null); const passwordPollAbortRef = useRef(null); const qrCloseTimerRef = useRef(null); const passwordPollTimerRef = useRef(null); const passwordPollGenerationRef = useRef(0); if (qrPollerRef.current === null) { qrPollerRef.current = createQRLoginPoller(); } if (qrRequestGateRef.current === null) { qrRequestGateRef.current = createLatestRequestGate(); } if (accountLoadGateRef.current === null) accountLoadGateRef.current = createLatestRequestGate(); if (bindingsLoadGateRef.current === null) bindingsLoadGateRef.current = createLatestRequestGate(); if (aiLoadGateRef.current === null) aiLoadGateRef.current = createLatestRequestGate(); const clearQRCloseTimer = () => { if (qrCloseTimerRef.current !== null) { window.clearTimeout(qrCloseTimerRef.current); qrCloseTimerRef.current = null; } }; const clearPasswordPollTimer = () => { if (passwordPollTimerRef.current !== null) { window.clearTimeout(passwordPollTimerRef.current); passwordPollTimerRef.current = null; } }; const stopQRPolling = () => { qrPollerRef.current?.stop(); }; const closeQRModal = () => { qrGenerateAbortRef.current?.abort(); qrRequestGateRef.current?.cancel(); stopQRPolling(); clearQRCloseTimer(); setShowQRModal(false); }; const scheduleQRModalClose = () => { clearQRCloseTimer(); qrCloseTimerRef.current = window.setTimeout(() => { qrCloseTimerRef.current = null; setShowQRModal(false); loadAccounts(); }, 1000); }; const loadAccounts = async () => { const generation = accountLoadGateRef.current!.next(); accountLoadAbortRef.current?.abort(); const controller = new AbortController(); accountLoadAbortRef.current = controller; setLoading(true); try { const options = { signal: controller.signal }; const [detailsResult, aiResult] = await Promise.allSettled([getAccountDetails(options), getAllAISettings(options)]); if (!accountLoadGateRef.current?.isCurrent(generation)) return; if (detailsResult.status === 'rejected') throw detailsResult.reason; const data = detailsResult.value; const allAISettings = aiResult.status === 'fulfilled' ? aiResult.value : {}; if (aiResult.status === 'rejected') console.error('Failed to load AI settings:', aiResult.reason); // 合并AI设置到账号数据 const accountsWithAI = data.map(account => ({ ...account, ai_enabled: allAISettings[account.id]?.ai_enabled ?? false, max_discount_percent: allAISettings[account.id]?.max_discount_percent ?? 10, max_discount_amount: allAISettings[account.id]?.max_discount_amount ?? 100, max_bargain_rounds: allAISettings[account.id]?.max_bargain_rounds ?? 3, custom_prompts: allAISettings[account.id]?.custom_prompts ?? '', })); if (accountLoadGateRef.current?.isCurrent(generation)) setAccounts(accountsWithAI); } catch (error) { if (accountLoadGateRef.current?.isCurrent(generation) && !controller.signal.aborted) { console.error('Failed to load accounts:', error); } } finally { if (accountLoadGateRef.current?.isCurrent(generation)) setLoading(false); } }; useEffect(() => { let cancelled = false; let timer: number | null = null; const runtimeController = new AbortController(); const pollRuntimeStatuses = async () => { try { const statuses = await getAccountRuntimeStatuses({ signal: runtimeController.signal, timeoutMs: 10_000 }); if (!cancelled) { setAccounts(current => mergeAccountRuntimeStatuses(current, statuses)); } } catch (error) { if (!cancelled) console.error('Failed to load account runtime statuses:', error); } finally { if (!cancelled) { // 运行时状态只读取本地内存;短轮询让风控恢复提示在约 2 秒内收敛。 timer = window.setTimeout(() => void pollRuntimeStatuses(), 2_000); } } }; void loadAccounts().finally(() => { if (!cancelled) void pollRuntimeStatuses(); }); return () => { cancelled = true; runtimeController.abort(); if (timer !== null) window.clearTimeout(timer); }; }, []); useEffect(() => { return () => { stopQRPolling(); qrRequestGateRef.current?.cancel(); accountLoadGateRef.current?.cancel(); bindingsLoadGateRef.current?.cancel(); aiLoadGateRef.current?.cancel(); accountLoadAbortRef.current?.abort(); bindingsLoadAbortRef.current?.abort(); aiLoadAbortRef.current?.abort(); qrGenerateAbortRef.current?.abort(); passwordPollAbortRef.current?.abort(); clearQRCloseTimer(); passwordPollGenerationRef.current += 1; clearPasswordPollTimer(); }; }, []); const runtimePresentation = (account: AccountDetail) => { if (!account.enabled || account.runtime_state === 'disabled') { return { label: '已停用', badge: 'bg-gray-100 text-gray-500', dot: 'bg-gray-300' }; } switch (account.runtime_state) { case 'online': return { label: '在线', badge: 'bg-green-100 text-green-700', dot: 'bg-green-500' }; case 'starting': case 'connecting': return { label: '连接中', badge: 'bg-blue-100 text-blue-700', dot: 'bg-blue-500' }; case 'reconnecting': return { label: '重连中', badge: 'bg-amber-100 text-amber-700', dot: 'bg-amber-500' }; case 'auth_expired': return { label: '登录已失效', badge: 'bg-red-100 text-red-700', dot: 'bg-red-500' }; case 'verification_required': return { label: '需要验证', badge: 'bg-orange-100 text-orange-700', dot: 'bg-orange-500' }; case 'error': case 'stopped': return { label: '运行异常', badge: 'bg-red-100 text-red-700', dot: 'bg-red-500' }; default: return { label: '状态检测中', badge: 'bg-gray-100 text-gray-600', dot: 'bg-gray-400' }; } }; const handleToggle = async (id: string, currentStatus: boolean) => { await updateAccountStatus(id, !currentStatus); loadAccounts(); }; const openDeleteDialog = (account: AccountDetail) => { if (deletingAccountId) return; setDeleteError(''); setDeleteDialogAccount(account); }; const closeDeleteDialog = () => { if (deletingAccountId) return; setDeleteError(''); setDeleteDialogAccount(null); }; const confirmDeleteAccount = async () => { const account = deleteDialogAccount; if (!account || deletingAccountId) return; setDeletingAccountId(account.id); setDeleteError(''); try { await deleteAccount(account.id); setAccounts(current => current.filter(item => item.id !== account.id)); setDeleteDialogAccount(null); } catch (error: any) { console.error('删除账号失败:', error); setDeleteError(error?.message || '删除账号失败,请稍后重试'); } finally { setDeletingAccountId(''); } }; const handleRefreshProfile = async (account: AccountDetail) => { setRefreshingProfileId(account.id); try { const res = await refreshAccountProfile(account.id); if (res?.profile_error) { alert('资料刷新失败:' + res.profile_error); } await loadAccounts(); } catch (error: any) { console.error('刷新账号资料失败:', error); alert(error?.message || '刷新账号资料失败,请先重新授权该账号'); } finally { setRefreshingProfileId(''); } }; const loadNotificationBindings = async (accountId: string) => { const generation = bindingsLoadGateRef.current!.next(); bindingsLoadAbortRef.current?.abort(); const controller = new AbortController(); bindingsLoadAbortRef.current = controller; setBindingsLoading(true); setBindingsLoaded(false); setBindingsDirty(false); setBindingsLoadError(''); const [channelsResult, bindingsResult] = await Promise.allSettled([ getNotificationChannels({ signal: controller.signal }), getAccountBindings(accountId, { signal: controller.signal }), ]); if (!bindingsLoadGateRef.current?.isCurrent(generation)) return; if (channelsResult.status === 'fulfilled') { setNotifChannels(channelsResult.value.data || []); } else { setNotifChannels([]); setBindingsLoadError('通知渠道列表加载失败,请重试'); } if (bindingsResult.status === 'fulfilled') { setSelectedChannelIds(bindingsResult.value || []); setBindingsLoaded(true); } else { setSelectedChannelIds([]); setBindingsLoadError('通知绑定加载失败;本次保存不会修改现有绑定'); } setBindingsLoading(false); }; const openEditModal = async (account: AccountDetail) => { passwordPollGenerationRef.current += 1; passwordPollAbortRef.current?.abort(); clearPasswordPollTimer(); setPasswordLoginView({ sessionId: '', status: 'idle', message: '', qrCodeUrl: '' }); setEditingAccount(account); setEditForm({ remark: account.remark || account.note || '', cookie: account.cookie || account.value || '', auto_confirm: account.auto_confirm || false, pause_duration: account.pause_duration || 0, username: account.username || '', login_password: account.login_password || '', show_browser: account.show_browser || false, showLoginPassword: false, clear_password: false, }); setActiveModal('edit'); setLongLogin({ loading: true, saving: false, canOpen: false, enabled: false, error: '' }); const [, longLoginResult] = await Promise.allSettled([ loadNotificationBindings(account.id), getLongLoginSettings(account.id), ]); if (longLoginResult.status === 'fulfilled') { setLongLogin({ loading: false, saving: false, canOpen: longLoginResult.value.can_open_long_login, enabled: longLoginResult.value.enabled, error: '' }); } else { setLongLogin({ loading: false, saving: false, canOpen: false, enabled: false, error: '无法读取闲鱼保存登录信息状态' }); } }; const handleLongLoginToggle = async () => { if (!editingAccount || longLogin.loading || longLogin.saving || !longLogin.canOpen) return; const enabled = !longLogin.enabled; setLongLogin(current => ({ ...current, saving: true, error: '' })); try { const result = await setLongLoginSettings(editingAccount.id, enabled); setLongLogin({ loading: false, saving: false, canOpen: result.can_open_long_login, enabled: result.enabled, error: '' }); } catch (error) { setLongLogin(current => ({ ...current, saving: false, error: error instanceof Error ? error.message : '保存登录信息设置失败' })); } }; const openAIModal = async (account: AccountDetail) => { const generation = aiLoadGateRef.current!.next(); aiLoadAbortRef.current?.abort(); const controller = new AbortController(); aiLoadAbortRef.current = controller; setEditingAccount(account); setActiveModal('ai-settings'); setSaving(true); try { const settings = await getAccountAISettings(account.id, { signal: controller.signal }); if (!aiLoadGateRef.current?.isCurrent(generation)) return; setAiSettings({ ai_enabled: settings.ai_enabled ?? false, max_discount_percent: settings.max_discount_percent ?? 10, max_discount_amount: settings.max_discount_amount ?? 100, max_bargain_rounds: settings.max_bargain_rounds ?? 3, custom_prompts: settings.custom_prompts ?? '', }); } catch (e) { if (aiLoadGateRef.current?.isCurrent(generation)) console.error('Failed to load AI settings:', e); } finally { if (aiLoadGateRef.current?.isCurrent(generation)) setSaving(false); } }; const handleSaveEdit = async () => { if (!editingAccount) return; setSaving(true); try { const payload: Parameters[1] = {}; // 更新备注 if (editForm.remark !== (editingAccount.remark || editingAccount.note || '')) { payload.remark = editForm.remark; } // 更新Cookie if (editForm.cookie && editForm.cookie !== (editingAccount.cookie || editingAccount.value || '')) { payload.cookie = editForm.cookie; } // 更新自动确认 if (editForm.auto_confirm !== editingAccount.auto_confirm) { payload.auto_confirm = editForm.auto_confirm; } // 更新暂停时长 if (shouldUpdateAccountPause(editForm.pause_duration, editingAccount)) { payload.pause_duration = editForm.pause_duration; } // 更新登录信息 const loginInfo = buildAccountLoginInfoUpdate(editingAccount, editForm); if (loginInfo) { Object.assign(payload, loginInfo); } // 只有成功加载且用户确实改动后才覆盖,避免加载失败被误解释成解绑全部。 if (shouldSaveNotificationBindings(bindingsLoaded, bindingsDirty)) { payload.channel_ids = selectedChannelIds; } if (Object.keys(payload).length > 0) await updateAccountSettings(editingAccount.id, payload); setActiveModal(null); loadAccounts(); } catch (error) { console.error('更新账号失败:', error); alert('更新失败,请重试'); } finally { setSaving(false); } }; const handleRestartPause = async () => { if (!editingAccount || editForm.pause_duration <= 0) return; setSaving(true); try { const result = await updateAccountPauseDuration(editingAccount.id, editForm.pause_duration); setEditingAccount({ ...editingAccount, pause_duration: editForm.pause_duration, paused: result?.paused === true, paused_until: Number(result?.paused_until || 0), }); await loadAccounts(); } catch (error) { alert(error instanceof Error ? error.message : '重新暂停失败'); } finally { setSaving(false); } }; const handleSaveAISettings = async () => { if (!editingAccount) return; setSaving(true); try { await updateAccountAISettings(editingAccount.id, aiSettings); setActiveModal(null); loadAccounts(); } catch (error) { console.error('更新AI设置失败:', error); alert('更新失败,请重试'); } finally { setSaving(false); } }; const pollPasswordLogin = async (sessionId: string, generation: number) => { passwordPollAbortRef.current?.abort(); const controller = new AbortController(); passwordPollAbortRef.current = controller; try { const result = await checkPasswordLoginStatus(sessionId, controller.signal); if (generation !== passwordPollGenerationRef.current) return; if (result.status === 'success') { clearPasswordPollTimer(); setPasswordLoginView({ sessionId, status: 'success', message: result.message || '账号密码登录成功,授权信息已更新', qrCodeUrl: '', }); setEditForm(current => ({ ...current, login_password: '', showLoginPassword: false })); await loadAccounts(); return; } if (result.status === 'processing' || result.status === 'verification_required') { setPasswordLoginView({ sessionId, status: result.status, message: result.message || (result.status === 'verification_required' ? '账号触发风控,需要完成人脸识别' : '登录处理中'), qrCodeUrl: result.qr_code_url || '', }); clearPasswordPollTimer(); passwordPollTimerRef.current = window.setTimeout(() => void pollPasswordLogin(sessionId, generation), 1500); return; } clearPasswordPollTimer(); setPasswordLoginView({ sessionId, status: 'failed', message: result.error || result.message || '密码登录失败,请检查账号信息后重试', qrCodeUrl: '', }); } catch (error) { if (generation !== passwordPollGenerationRef.current) return; clearPasswordPollTimer(); setPasswordLoginView({ sessionId, status: 'failed', message: error instanceof Error ? error.message : '查询密码登录状态失败', qrCodeUrl: '', }); } }; const handlePasswordLogin = async () => { if (!editingAccount) return; const account = editForm.username.trim(); if (!account || !editForm.login_password) { alert('请先填写登录账号和本次登录密码'); return; } clearPasswordPollTimer(); passwordPollAbortRef.current?.abort(); const generation = ++passwordPollGenerationRef.current; setPasswordLoginView({ sessionId: '', status: 'processing', message: '正在启动密码登录…', qrCodeUrl: '' }); try { const result = await passwordLogin({ account_id: editingAccount.id, account, password: editForm.login_password, show_browser: editForm.show_browser, }); if (generation !== passwordPollGenerationRef.current) return; if (!result.success || !result.session_id) { throw new Error(result.message || '无法启动密码登录'); } setPasswordLoginView({ sessionId: result.session_id, status: 'processing', message: result.message || '登录处理中', qrCodeUrl: '' }); await pollPasswordLogin(result.session_id, generation); } catch (error) { if (generation !== passwordPollGenerationRef.current) return; setPasswordLoginView({ sessionId: '', status: 'failed', message: error instanceof Error ? error.message : '启动密码登录失败', qrCodeUrl: '', }); } }; const handleCancelPasswordLogin = async () => { const sessionId = passwordLoginView.sessionId; passwordPollGenerationRef.current += 1; passwordPollAbortRef.current?.abort(); clearPasswordPollTimer(); if (sessionId) { try { await cancelPasswordLogin(sessionId); } catch (error) { console.error('取消密码登录失败', error); } } setPasswordLoginView({ sessionId: '', status: 'idle', message: '', qrCodeUrl: '' }); }; const closeEditModal = async () => { bindingsLoadGateRef.current?.cancel(); bindingsLoadAbortRef.current?.abort(); if (passwordLoginView.status === 'processing' || passwordLoginView.status === 'verification_required') { await handleCancelPasswordLogin(); } setActiveModal(null); }; const closeAIModal = () => { aiLoadGateRef.current?.cancel(); aiLoadAbortRef.current?.abort(); setActiveModal(null); }; const completeAndPersistQRSession = async (sessionId: string, target?: AccountDetail | null) => { const res = await completeQRVerification(sessionId, target?.id); if (!res.success || !res.account_id) { throw new Error(res.message || '保存扫码授权失败'); } return res.account_id; }; const startQRLogin = async (target?: AccountDetail) => { stopQRPolling(); qrGenerateAbortRef.current?.abort(); const controller = new AbortController(); qrGenerateAbortRef.current = controller; const requestGeneration = qrRequestGateRef.current!.next(); clearQRCloseTimer(); const targetAccount = target || null; setQrReauthTarget(targetAccount); setShowQRModal(true); setQrStatus('loading'); setQrCodeUrl(''); setVerificationScreenshot(''); setFaceQrUrl(''); try { const res = await generateQRLogin({ signal: controller.signal }); if (!qrRequestGateRef.current?.isCurrent(requestGeneration)) return; if (res.success && res.qr_code_url && res.session_id) { const generatedSessionID = res.session_id; setQrCodeUrl(res.qr_code_url); setQrStatus('waiting'); qrPollerRef.current?.start(generatedSessionID, checkQRLoginStatus, { onSuccess: async () => { try { const accountId = await completeAndPersistQRSession(generatedSessionID, targetAccount); if (!accountId) { setQrStatus('error'); return; } } catch (e) { console.error('保存扫码授权失败', e); setQrStatus('error'); return; } setQrStatus('success'); scheduleQRModalClose(); }, onScanned: () => { setQrStatus('waiting'); // 已扫描,继续等待确认 }, onTerminalError: () => { setQrStatus('error'); }, onPollError: (error) => { console.error('轮询扫码状态失败', error); setQrStatus('error'); }, onVerificationRequired: (statusRes) => { setQrStatus('verification'); if (statusRes.face_qr_url) { setFaceQrUrl(statusRes.face_qr_url); } if (statusRes.verification_screenshot) { setVerificationScreenshot(statusRes.verification_screenshot); } }, }); } } catch (e) { if (!qrRequestGateRef.current?.isCurrent(requestGeneration)) return; setQrStatus('error'); } }; if (loading) return
; const filteredAccounts = accounts.filter(account => { const keyword = accountSearch.trim().toLowerCase(); if (!keyword) return true; return [ account.id, account.nickname, account.remark, account.note, account.username, account.runtime_message, ].some(value => (value || '').toLowerCase().includes(keyword)); }); return (

账号管理

管理您的闲鱼授权账号及设置。建议给账号填写备注,便于多账号区分。

setAccountSearch(event.target.value)} placeholder="搜索昵称 / 备注 / 账号ID" className="ios-input px-4 py-3 rounded-2xl text-sm w-full sm:w-72" />
当前显示 {filteredAccounts.length} / {accounts.length} 个账号
如果某个账号只显示 ID,点该账号右侧“刷新资料”;若刷新失败,先点二维码重新授权。
{/* Account Grid */}
{filteredAccounts.map((account) => { const runtime = runtimePresentation(account); 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.profile_error && ( 资料未同步 )}

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

ID: {account.id}

{account.runtime_message && account.runtime_state !== 'online' && account.runtime_state !== 'disabled' && (
{account.runtime_message} {requiresLogin && ( )}
)}
{account.auto_confirm && 自动确认发货} {account.paused && 暂停处理中}
)})} {accounts.length === 0 && (

暂无账号

请点击右上角扫码添加您的闲鱼账号

)} {accounts.length > 0 && filteredAccounts.length === 0 && (

没有匹配的账号

换一个关键词搜索昵称、备注或账号ID。

)}
{/* 删除账号确认弹窗 */} {deleteDialogAccount && createPortal(

删除这个账号?

删除后,该账号的关联配置也会一并清理,此操作无法撤销。

{deleteDialogAccount.nickname || deleteDialogAccount.remark || '未命名账号'}
{deleteDialogAccount.remark && deleteDialogAccount.nickname && (
备注:{deleteDialogAccount.remark}
)}
ID: {deleteDialogAccount.id}
{deletingAccountId === deleteDialogAccount.id && (
正在删除账号
正在清理关联数据,请保持页面打开…
)} {deleteError && (
删除失败
{deleteError}
)}
, document.body )} {/* QR Code Modal */} {showQRModal && createPortal(

{qrReauthTarget ? '重新授权账号' : '扫码添加账号'}

{qrReauthTarget ? `请用闲鱼APP扫码,为「${qrReauthTarget.nickname || qrReauthTarget.remark || qrReauthTarget.id}」刷新授权` : '请打开闲鱼APP扫描下方二维码'}

{qrStatus === 'loading' && } {qrStatus === 'waiting' && } {qrStatus === 'success' && (
登录成功
)} {qrStatus === 'error' && (
二维码获取失败 请关闭窗口后重新发起扫码登录。
)} {qrStatus === 'verification' && ( )}
{qrStatus !== 'verification' &&

二维码有效期为5分钟,请尽快扫码。

}
, document.body )} {/* 编辑账号弹窗 */} {activeModal === 'edit' && editingAccount && createPortal(

编辑账号

{editingAccount.nickname || editingAccount.remark || editingAccount.id}

{/* 账号ID */}
{/* 备注 */}
setEditForm({ ...editForm, remark: e.target.value })} placeholder="为账号添加备注" className="w-full ios-input px-4 py-3 rounded-xl" />
{/* Cookie */}