/** * 运营统计看板 * * 展示 DAU/DAT、模块使用统计、实时流水账 */ import { useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { Card, Statistic, Row, Col, Table, Tag, Spin, Empty, Tooltip } from 'antd'; import { UserOutlined, BankOutlined, ExportOutlined, MessageOutlined, BookOutlined, SearchOutlined, FileTextOutlined, SyncOutlined, LoginOutlined, CloudUploadOutlined, DeleteOutlined, WarningOutlined, ReloadOutlined, } from '@ant-design/icons'; import { getOverview, getLiveFeed } from '../api/statsApi'; import type { OverviewData, ActivityLog } from '../api/statsApi'; // ==================== 模块图标映射 ==================== const MODULE_ICONS: Record = { 'SYSTEM': , 'AIA': , 'PKB': , 'ASL': , 'DC': , 'RVW': , 'IIT': , }; const MODULE_COLORS: Record = { 'SYSTEM': '#8c8c8c', 'AIA': '#1890ff', 'PKB': '#52c41a', 'ASL': '#722ed1', 'DC': '#fa8c16', 'RVW': '#eb2f96', 'IIT': '#13c2c2', }; const ACTION_ICONS: Record = { 'LOGIN': , 'USE': , 'EXPORT': , 'CREATE': , 'DELETE': , 'ERROR': , }; // ==================== 组件 ==================== export default function StatsDashboardPage() { const [liveFeedLimit] = useState(50); // 获取大盘数据 const { data: overview, isLoading: overviewLoading, refetch: refetchOverview } = useQuery({ queryKey: ['admin-stats-overview'], queryFn: getOverview, refetchInterval: 30000, // 30秒自动刷新 }); // 获取实时流水账 const { data: liveFeed, isLoading: liveFeedLoading, refetch: refetchLiveFeed } = useQuery({ queryKey: ['admin-stats-live-feed', liveFeedLimit], queryFn: () => getLiveFeed(liveFeedLimit), refetchInterval: 10000, // 10秒自动刷新 }); // 刷新所有数据 const handleRefresh = () => { refetchOverview(); refetchLiveFeed(); }; // 流水账表格列 const columns = [ { title: '时间', dataIndex: 'createdAt', key: 'createdAt', width: 90, render: (time: string) => { const date = new Date(time); return ( {date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit', second: '2-digit' })} ); }, }, { title: '动作', dataIndex: 'action', key: 'action', width: 80, render: (action: string) => ( {ACTION_ICONS[action] || null} {action} ), }, { title: '模块', dataIndex: 'module', key: 'module', width: 80, render: (module: string) => ( {module} ), }, { title: '功能', dataIndex: 'feature', key: 'feature', width: 150, ellipsis: true, }, { title: '用户', dataIndex: 'userName', key: 'userName', width: 100, render: (name: string | null, record: ActivityLog) => ( {name || '-'} ), }, { title: '详情', dataIndex: 'info', key: 'info', ellipsis: true, render: (info: string | null) => ( {info || '-'} ), }, ]; return (
{/* 页面标题 */}

运营监控看板

实时监控系统使用情况

{/* 核心指标卡片 */} 今日活跃医生 (DAU)} value={overview?.dau ?? 0} prefix={} loading={overviewLoading} valueStyle={{ color: '#1890ff', fontWeight: 'bold' }} /> 今日活跃租户 (DAT)} value={overview?.dat ?? 0} prefix={} loading={overviewLoading} valueStyle={{ color: '#52c41a', fontWeight: 'bold' }} /> 今日导出次数} value={overview?.exportCount ?? 0} prefix={} loading={overviewLoading} valueStyle={{ color: '#722ed1', fontWeight: 'bold' }} /> {/* 模块使用统计 */} {overview?.moduleStats && Object.keys(overview.moduleStats).length > 0 && ( 今日} > {Object.entries(overview.moduleStats).map(([module, count]) => (
{MODULE_ICONS[module] || }
{count}
{module}
))}
)} {/* 实时流水账 */} 最近 {liveFeedLimit} 条 · 10秒自动刷新 } > {liveFeedLoading ? (
) : liveFeed && liveFeed.length > 0 ? ( ) : ( )} {/* 自定义样式 */} ); }