import { useEffect, useState } from 'react' import { useParams, useNavigate } from 'react-router-dom' import { Card, Row, Col, Statistic, Tag, Button, message, Spin } from 'antd' import { ArrowUpOutlined, ArrowDownOutlined, LeftOutlined } from '@ant-design/icons' import { apiService } from '../services/api' import { formatUSDC, formatNumber } from '../utils' import { useMediaQuery } from 'react-responsive' import type { CopyTradingStatistics } from '../types' const CopyTradingStatisticsPage: React.FC = () => { const { copyTradingId } = useParams<{ copyTradingId: string }>() const navigate = useNavigate() useMediaQuery({ maxWidth: 768 }) // 用于响应式布局,但当前页面未使用 const [loading, setLoading] = useState(false) const [statistics, setStatistics] = useState(null) useEffect(() => { if (copyTradingId) { fetchStatistics() } }, [copyTradingId]) const fetchStatistics = async () => { if (!copyTradingId) return setLoading(true) try { const response = await apiService.statistics.detail({ copyTradingId: parseInt(copyTradingId) }) if (response.data.code === 0 && response.data.data) { setStatistics(response.data.data) } else { message.error(response.data.msg || '获取统计信息失败') } } catch (error: any) { message.error(error.message || '获取统计信息失败') } finally { setLoading(false) } } const getPnlColor = (value: string): string => { const num = parseFloat(value) if (isNaN(num)) return '#666' return num >= 0 ? '#3f8600' : '#cf1322' } const getPnlIcon = (value: string) => { const num = parseFloat(value) if (isNaN(num)) return null return num >= 0 ? : } const formatPercent = (value: string): string => { const num = parseFloat(value) if (isNaN(num)) return '-' return `${num >= 0 ? '+' : ''}${num.toFixed(2)}%` } if (loading) { return (
) } if (!statistics) { return (

暂无统计数据

) } return (

跟单关系统计

{/* 基本信息卡片 */}
账户名称
{statistics.accountName || `账户 ${statistics.accountId}`}
Leader 名称
{statistics.leaderName || `Leader ${statistics.leaderId}`}
跟单状态
{statistics.enabled ? '启用' : '禁用'}
{/* 买入统计卡片 */} {/* 卖出统计卡片 */} {/* 持仓统计卡片 */} {/* 盈亏统计卡片 */} {getPnlIcon(statistics.totalRealizedPnl)} $} /> {getPnlIcon(statistics.totalUnrealizedPnl)} $} /> {getPnlIcon(statistics.totalPnl)} $} />
) } export default CopyTradingStatisticsPage