1
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -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>
|
||||
|
||||
@@ -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 }}>
|
||||
|
||||
Reference in New Issue
Block a user