diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index 8228133..b51556f 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -1,4 +1,4 @@ -import { useMemo } from 'react' +import { useMemo, useState } from 'react' import { Row, Col, Typography } from 'antd' import { useQuery } from '@tanstack/react-query' import ReactEChartsCore from 'echarts-for-react/esm/core' @@ -7,10 +7,7 @@ import { LineChart, BarChart } from 'echarts/charts' import { GridComponent, TooltipComponent, TitleComponent, LegendComponent } from 'echarts/components' import { CanvasRenderer } from 'echarts/renderers' import { - UserOutlined, - BookOutlined, - CloudOutlined, - FileOutlined, + UserOutlined, BookOutlined, CloudOutlined, FileOutlined, } from '@ant-design/icons' import dayjs from 'dayjs' import MetricCard from '@/components/MetricCard' @@ -27,6 +24,9 @@ function formatStorage(bytes: number): string { } export default function Dashboard() { + const [auditPage, setAuditPage] = useState(1) + const [auditPageSize, setAuditPageSize] = useState(10) + const { data: stats, isLoading: statsLoading } = useQuery({ queryKey: ['dashboard', 'stats'], queryFn: getDashboardStats, @@ -34,8 +34,8 @@ export default function Dashboard() { }) const { data: auditData, isLoading: auditLoading } = useQuery({ - queryKey: ['dashboard', 'audit-logs'], - queryFn: () => getAuditLogs({ page: 1, limit: 10 }), + queryKey: ['dashboard', 'audit-logs', auditPage, auditPageSize], + queryFn: () => getAuditLogs({ page: auditPage, limit: auditPageSize }), staleTime: 30_000, }) @@ -49,11 +49,9 @@ export default function Dashboard() { }, yAxis: { type: 'value' as const, axisLabel: { fontSize: 11 } }, series: [{ - name: '日活用户', - type: 'line', + name: '日活用户', type: 'line', data: stats?.userTrend.map((p) => p.value) || [], - smooth: true, - symbol: 'none', + smooth: true, symbol: 'none', lineStyle: { color: '#1677ff', width: 2 }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: 'rgba(22,119,255,0.15)' }, @@ -72,13 +70,11 @@ export default function Dashboard() { }, yAxis: { type: 'value' as const, axisLabel: { fontSize: 11 } }, series: [{ - name: 'AI 调用', - type: 'bar', + name: 'AI 调用', type: 'bar', data: stats?.aiCallTrend.map((p) => p.value) || [], itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - { offset: 0, color: '#52c41a' }, - { offset: 1, color: '#b7eb8f' }, + { offset: 0, color: '#52c41a' }, { offset: 1, color: '#b7eb8f' }, ]), borderRadius: [4, 4, 0, 0], }, @@ -88,87 +84,43 @@ export default function Dashboard() { return (