This commit is contained in:
2026-07-21 10:08:00 +08:00
parent 76d03e7de1
commit 2a9c2d868c
4 changed files with 39 additions and 30 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
}
})();
</script>
<script type="module" crossorigin src="/assets/index-CkQa2uab.js"></script>
<script type="module" crossorigin src="/assets/index-W5ctKG_t.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
</head>
<body>
+30 -25
View File
@@ -84,32 +84,8 @@ const AdminDashboard: React.FC = () => {
</div>
</div>
{/* 图表区域 */}
<Row gutter={[16, 16]}>
<Col xs={24} lg={12}>
<ChartCard title="每日积分消耗趋势" loading={loading}>
<LineChart data={stats?.dailyCreditsByModule || []} />
</ChartCard>
</Col>
<Col xs={24} lg={12}>
<ChartCard title="各模块积分占比" loading={loading}>
<ModulePie data={stats?.dailyCreditsByModule || []} />
</ChartCard>
</Col>
<Col xs={24} lg={12}>
<ChartCard title="团队积分消耗排行" loading={loading}>
<HorizontalBarChart data={(stats?.creditsByTeam || []).slice(0, 8)} />
</ChartCard>
</Col>
<Col xs={24} lg={12}>
<ChartCard title="模型使用次数" loading={loading}>
<HorizontalBarChart data={(stats?.modelUsage || []).slice(0, 8)} valueKey="count" />
</ChartCard>
</Col>
</Row>
{/* 核心数据 */}
<div style={{ marginTop: 24 }}>
<div style={{ marginBottom: 20 }}>
<div style={{ marginBottom: 12 }}>
<Typography.Text strong style={{ fontSize: 15 }}></Typography.Text>
</div>
@@ -128,6 +104,35 @@ const AdminDashboard: React.FC = () => {
))}
</Row>
</div>
{/* 图表区域 */}
<div style={{ marginBottom: 20 }}>
<div style={{ marginBottom: 12 }}>
<Typography.Text strong style={{ fontSize: 15 }}></Typography.Text>
</div>
<Row gutter={[16, 16]}>
<Col xs={24} lg={12}>
<ChartCard title="每日积分消耗趋势" loading={loading}>
<LineChart data={stats?.dailyCreditsByModule || []} />
</ChartCard>
</Col>
<Col xs={24} lg={12}>
<ChartCard title="各模块积分占比" loading={loading}>
<ModulePie data={stats?.dailyCreditsByModule || []} />
</ChartCard>
</Col>
<Col xs={24} lg={12}>
<ChartCard title="团队积分消耗排行" loading={loading}>
<HorizontalBarChart data={(stats?.creditsByTeam || []).slice(0, 8)} />
</ChartCard>
</Col>
<Col xs={24} lg={12}>
<ChartCard title="模型使用次数" loading={loading}>
<HorizontalBarChart data={(stats?.modelUsage || []).slice(0, 8)} valueKey="count" />
</ChartCard>
</Col>
</Row>
</div>
</div>
);
};
+7 -3
View File
@@ -1856,8 +1856,8 @@ async def get_stats(
)
)).scalar() or 0
# ── 每日各模块积分消耗(按日期+模块分组)
daily_credits_rows = (await db.execute(
# ── 每日各模块积分消耗(按日期+模块分组,子查询排序避免 PG GROUP BY 限制
_daily_subq = (
select(
func.to_char(CreditRecord.created_at, 'YYYY-MM-DD').label('date'),
func.coalesce(CreditRecord.source_module, 'other').label('module'),
@@ -1869,7 +1869,11 @@ async def get_stats(
CreditRecord.created_at <= date_end,
)
.group_by(func.to_char(CreditRecord.created_at, 'YYYY-MM-DD'), func.coalesce(CreditRecord.source_module, 'other'))
.order_by(func.to_char(CreditRecord.created_at, 'YYYY-MM-DD'))
.subquery()
)
daily_credits_rows = (await db.execute(
select(_daily_subq.c.date, _daily_subq.c.module, _daily_subq.c.credits)
.order_by(_daily_subq.c.date)
)).all()
daily_credits_by_module = [
DailyCreditOut(date=row.date, module=row.module, credits=float(row.credits or 0))