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" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>VideoGen.AI 管理后台</title>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import {
|
|||||||
ArrowUpOutlined,
|
ArrowUpOutlined,
|
||||||
CalendarOutlined,
|
CalendarOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { getAdminStats } from '../api';
|
import { getAdminStats, getSystemConfigs } from '../api';
|
||||||
import type { AdminStats } from '../types';
|
import type { AdminStats, SystemConfig } from '../types';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import 'dayjs/locale/zh-cn';
|
import 'dayjs/locale/zh-cn';
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ const AdminDashboard: React.FC = () => {
|
|||||||
const [stats, setStats] = useState<AdminStats | null>(null);
|
const [stats, setStats] = useState<AdminStats | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [startDate, setStartDate] = useState<[dayjs.Dayjs | null, dayjs.Dayjs | null]>([dayjs().startOf('day'), dayjs()]);
|
const [startDate, setStartDate] = useState<[dayjs.Dayjs | null, dayjs.Dayjs | null]>([dayjs().startOf('day'), dayjs()]);
|
||||||
|
const [siteName, setSiteName] = useState<string>('数据概览');
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -33,33 +34,49 @@ const AdminDashboard: React.FC = () => {
|
|||||||
setLoading(false);
|
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(() => {
|
useEffect(() => {
|
||||||
load();
|
load();
|
||||||
|
loadSiteName();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleDateChange = () => {
|
|
||||||
load();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleToday = () => {
|
const handleToday = () => {
|
||||||
setStartDate([dayjs().startOf('day'), dayjs()]);
|
setStartDate([dayjs().startOf('day'), dayjs()]);
|
||||||
setTimeout(() => load(), 0);
|
load();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleYesterday = () => {
|
const handleYesterday = () => {
|
||||||
const yesterday = dayjs().subtract(1, 'day');
|
const yesterday = dayjs().subtract(1, 'day');
|
||||||
setStartDate([yesterday.startOf('day'), yesterday.endOf('day')]);
|
setStartDate([yesterday.startOf('day'), yesterday.endOf('day')]);
|
||||||
setTimeout(() => load(), 0);
|
load();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleWeek = () => {
|
const handleWeek = () => {
|
||||||
setStartDate([dayjs().startOf('week'), dayjs()]);
|
setStartDate([dayjs().startOf('week'), dayjs()]);
|
||||||
setTimeout(() => load(), 0);
|
load();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMonth = () => {
|
const handleMonth = () => {
|
||||||
setStartDate([dayjs().startOf('month'), dayjs()]);
|
setStartDate([dayjs().startOf('month'), dayjs()]);
|
||||||
setTimeout(() => load(), 0);
|
load();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDateChange = (dates: any) => {
|
||||||
|
if (dates) {
|
||||||
|
setStartDate([dates[0], dates[1]]);
|
||||||
|
load();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseStats = stats ? [
|
const baseStats = stats ? [
|
||||||
@@ -258,7 +275,7 @@ const AdminDashboard: React.FC = () => {
|
|||||||
}} />
|
}} />
|
||||||
<div style={{ position: 'relative', zIndex: 1 }}>
|
<div style={{ position: 'relative', zIndex: 1 }}>
|
||||||
<Typography.Title level={2} style={{ color: '#fff', marginBottom: 4, fontWeight: 700 }}>
|
<Typography.Title level={2} style={{ color: '#fff', marginBottom: 4, fontWeight: 700 }}>
|
||||||
数据概览
|
{siteName}
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Typography.Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: 14 }}>
|
<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 }} />
|
<CalendarOutlined style={{ color: '#64748b', fontSize: 14 }} />
|
||||||
<DatePicker.RangePicker
|
<DatePicker.RangePicker
|
||||||
value={startDate}
|
value={startDate}
|
||||||
onChange={(dates) => { if (dates) setStartDate([dates[0], dates[1]]); }}
|
onChange={handleDateChange}
|
||||||
onBlur={handleDateChange}
|
|
||||||
placeholder={['开始日期', '结束日期']}
|
placeholder={['开始日期', '结束日期']}
|
||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
onClick={handleDateChange}
|
|
||||||
style={{ borderRadius: 6 }}
|
|
||||||
>
|
|
||||||
查询
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ marginBottom: 16, paddingLeft: 4 }}>
|
<div style={{ marginBottom: 16, paddingLeft: 4 }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user