Files
live-hub-py/web/frontend/src/pages/DashboardPage.tsx
T
yml2213andClaude Fable 5 4522421293 增加自动亮色/暗色主题切换 + 清理 pyc 文件
- 新建 store/theme.tsx: 亮色/暗色/跟随系统三种模式
- App.tsx: ThemeProvider + ConfigProvider 暗色算法
- MainLayout: 侧边栏主题切换按钮,Sider/Content 随主题变化
- 所有页面硬编码颜色替换为 antd token
- AssignmentsPage: Tag 用预设颜色名适配暗色,未选中背景用 colorBgContainer
- LoginPage: 暗色深色渐变背景
- 从 git 移除所有 __pycache__/*.pyc 文件

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-22 20:09:57 +08:00

50 lines
1.5 KiB
TypeScript

import { Card, Col, Row, Statistic, theme } from 'antd';
import { useEffect, useState } from 'react';
import { accountApi, loginApi } from '../api/modules';
export default function DashboardPage() {
const { token } = theme.useToken();
const [stats, setStats] = useState({ accounts: 0, tasks: 0, success: 0, failed: 0 });
useEffect(() => {
Promise.all([accountApi.list(), loginApi.listTasks()])
.then(([accounts, tasks]) => {
setStats({
accounts: accounts.length,
tasks: tasks.length,
success: tasks.filter((t: any) => t.status === 'success').length,
failed: tasks.filter((t: any) => ['failed', 'error'].includes(t.status)).length,
});
})
.catch(() => {});
}, []);
return (
<div>
<h2>概览</h2>
<Row gutter={16}>
<Col span={6}>
<Card>
<Statistic title="账号总数" value={stats.accounts} />
</Card>
</Col>
<Col span={6}>
<Card>
<Statistic title="登录任务总数" value={stats.tasks} />
</Card>
</Col>
<Col span={6}>
<Card>
<Statistic title="成功" value={stats.success} valueStyle={{ color: token.colorSuccess }} />
</Card>
</Col>
<Col span={6}>
<Card>
<Statistic title="失败" value={stats.failed} valueStyle={{ color: token.colorError }} />
</Card>
</Col>
</Row>
</div>
);
}