import { ApiOutlined, MessageOutlined, RiseOutlined, TeamOutlined, ThunderboltOutlined } from '@ant-design/icons'; import { Line, Pie } from '@ant-design/charts'; import { ProCard } from '@ant-design/pro-components'; import { Col, Progress, Row, Select, Space, Statistic, Table, Tag, Typography, theme } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import type { ReactNode } from 'react'; import { themeConfig } from '@/styles/theme'; import { alertList, conversationTrend, modelShare, overviewStats, topModels, type AlertItem, type OverviewStat, } from './mock'; const iconMap: Record = { message: , token: , user: , api: , }; const alertColumns: ColumnsType = [ { title: '类型', dataIndex: 'type', width: 100 }, { title: '内容', dataIndex: 'content', ellipsis: true }, { title: '级别', dataIndex: 'level', width: 80, render: (level: AlertItem['level']) => { const color = level === '高' ? 'error' : level === '中' ? 'warning' : 'default'; return {level}; }, }, { title: '时间', dataIndex: 'time', width: 170 }, { title: '状态', dataIndex: 'status', width: 90, render: (status: AlertItem['status']) => {status}, }, ]; const primary = themeConfig.token.colorPrimary; export default function Dashboard() { const { token } = theme.useToken(); const lineConfig = { data: conversationTrend, xField: 'date', yField: 'value', height: 280, autoFit: true, // 给曲线/圆点留边,避免贴边裁切 padding: [12, 16, 8, 8], // 上 右 下 左,可按观感微调 // 或用 inset: 12 / insetRight: 16 shapeField: 'smooth', style: { stroke: primary, lineWidth: 2, }, area: { style: { fill: `linear-gradient(-90deg, ${primary}00 0%, ${primary}40 100%)`, }, }, point: { sizeField: 4, shapeField: 'circle', style: { fill: primary, stroke: '#fff', lineWidth: 1, }, }, axis: { y: { labelFormatter: (v: number) => `${Math.round(v / 1000)}k`, }, }, tooltip: { items: [{ channel: 'y', name: '对话量' }], }, }; const pieConfig = { data: modelShare, angleField: 'value', colorField: 'type', height: 280, innerRadius: 0.6, legend: { color: { position: 'right' as const, itemLabelFontSize: 12, }, }, label: false, annotations: [ { type: 'text' as const, style: { text: '总计\n100%', x: '50%', y: '50%', textAlign: 'center', fontSize: 14, fill: token.colorTextSecondary, }, }, ], }; return ( {overviewStats.map(item => ( {iconMap[item.icon]} {item.title} } value={item.value} suffix={ 较昨日 ↑ {item.trend}% } /> ))} } > rowKey="id" size="middle" columns={alertColumns} dataSource={alertList} pagination={{ pageSize: 5, showTotal: total => `共 ${total} 条` }} /> 查看更多 > } > {topModels.map((item, index) => (
{index + 1}. {item.name} {item.percent}%
))}
); }