import React from 'react';
import {
Card, Spin, Row, Col, Statistic,
} from 'antd';
import {
useQuery,
} from '@tanstack/react-query';
import { Line , Pie, Column} from "@ant-design/plots";
import 'dayjs/locale/zh-cn';
import { ChartAPI } from './api/index.ts';
import { useTheme } from './hooks_sys.tsx';
// 用户活跃度图表组件
const UserActivityChart: React.FC = () => {
const { isDark } = useTheme();
const { data: activityData, isLoading } = useQuery({
queryKey: ['userActivity'],
queryFn: async () => {
const response = await ChartAPI.getUserActivity();
return response.data;
}
});
if (isLoading) return ;
const config = {
data: activityData || [],
xField: 'date',
yField: 'count',
smooth: true,
theme: isDark ? 'dark' : 'light',
color: '#1890ff',
areaStyle: {
fill: 'l(270) 0:#1890ff10 1:#1890ff',
},
};
return (
);
};
// 文件上传统计图表组件
const FileUploadsChart: React.FC = () => {
const { isDark } = useTheme();
const { data: uploadsData, isLoading } = useQuery({
queryKey: ['fileUploads'],
queryFn: async () => {
const response = await ChartAPI.getFileUploads();
return response.data;
}
});
if (isLoading) return ;
const config = {
data: uploadsData || [],
xField: 'month',
yField: 'count',
theme: isDark ? 'dark' : 'light',
color: '#52c41a',
label: {
position: 'middle',
style: {
fill: '#FFFFFF',
opacity: 0.6,
},
},
meta: {
month: {
alias: '月份',
},
count: {
alias: '上传数量',
},
},
};
return (
);
};
// 文件类型分布图表组件
const FileTypesChart: React.FC = () => {
const { isDark } = useTheme();
const { data: typesData, isLoading } = useQuery({
queryKey: ['fileTypes'],
queryFn: async () => {
const response = await ChartAPI.getFileTypes();
return response.data;
}
});
if (isLoading) return ;
const config = {
data: typesData || [],
angleField: 'value',
colorField: 'type',
radius: 0.8,
theme: isDark ? 'dark' : 'light',
label: {
type: 'spider',
labelHeight: 28,
content: '{name}\n{percentage}',
},
interactions: [
{
type: 'element-active',
},
],
};
return (
);
};
// 仪表盘概览组件
const DashboardOverview: React.FC = () => {
const { data: overviewData, isLoading } = useQuery({
queryKey: ['dashboardOverview'],
queryFn: async () => {
const response = await ChartAPI.getDashboardOverview();
return response.data;
}
});
if (isLoading) return ;
return (
);
};
// 图表仪表盘页面组件
export const ChartDashboardPage: React.FC = () => {
return (
);
};