This commit is contained in:
2026-06-15 16:26:29 +08:00
parent aa2a971ffa
commit e1e9bf9aca
3 changed files with 31 additions and 23 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>VideoGen.AI 管理后台</title>
<script type="module" crossorigin src="/assets/index-D8zG-fgv.js"></script>
<script type="module" crossorigin src="/assets/index-CshLDvYK.js"></script>
</head>
<body>
<div id="root"></div>
+29 -21
View File
@@ -10,8 +10,8 @@ import {
ArrowUpOutlined,
CalendarOutlined,
} from '@ant-design/icons';
import { getAdminStats } from '../api';
import type { AdminStats } from '../types';
import { getAdminStats, getSystemConfigs } from '../api';
import type { AdminStats, SystemConfig } from '../types';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
@@ -21,6 +21,7 @@ const AdminDashboard: React.FC = () => {
const [stats, setStats] = useState<AdminStats | null>(null);
const [loading, setLoading] = useState(true);
const [startDate, setStartDate] = useState<[dayjs.Dayjs | null, dayjs.Dayjs | null]>([dayjs().startOf('day'), dayjs()]);
const [siteName, setSiteName] = useState<string>('数据概览');
const load = async () => {
setLoading(true);
@@ -33,33 +34,49 @@ const AdminDashboard: React.FC = () => {
setLoading(false);
};
const loadSiteName = async () => {
try {
const configs = await getSystemConfigs();
const siteConfig = configs.find((c: SystemConfig) => c.key === 'site_name');
if (siteConfig) {
setSiteName(`${siteConfig.value} 管理后台`);
}
} catch {
setSiteName('数据概览');
}
};
useEffect(() => {
load();
loadSiteName();
}, []);
const handleDateChange = () => {
load();
};
const handleToday = () => {
setStartDate([dayjs().startOf('day'), dayjs()]);
setTimeout(() => load(), 0);
load();
};
const handleYesterday = () => {
const yesterday = dayjs().subtract(1, 'day');
setStartDate([yesterday.startOf('day'), yesterday.endOf('day')]);
setTimeout(() => load(), 0);
load();
};
const handleWeek = () => {
setStartDate([dayjs().startOf('week'), dayjs()]);
setTimeout(() => load(), 0);
load();
};
const handleMonth = () => {
setStartDate([dayjs().startOf('month'), dayjs()]);
setTimeout(() => load(), 0);
load();
};
const handleDateChange = (dates: any) => {
if (dates) {
setStartDate([dates[0], dates[1]]);
load();
}
};
const baseStats = stats ? [
@@ -258,7 +275,7 @@ const AdminDashboard: React.FC = () => {
}} />
<div style={{ position: 'relative', zIndex: 1 }}>
<Typography.Title level={2} style={{ color: '#fff', marginBottom: 4, fontWeight: 700 }}>
{siteName}
</Typography.Title>
<Typography.Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: 14 }}>
@@ -302,19 +319,10 @@ const AdminDashboard: React.FC = () => {
<CalendarOutlined style={{ color: '#64748b', fontSize: 14 }} />
<DatePicker.RangePicker
value={startDate}
onChange={(dates) => { if (dates) setStartDate([dates[0], dates[1]]); }}
onBlur={handleDateChange}
onChange={handleDateChange}
placeholder={['开始日期', '结束日期']}
size="small"
/>
<Button
type="primary"
size="small"
onClick={handleDateChange}
style={{ borderRadius: 6 }}
>
</Button>
</div>
</div>
<div style={{ marginBottom: 16, paddingLeft: 4 }}>