sync: soul-admin 前端、soul-admin 页面 | 原因: 前端代码修改、前端页面修改
This commit is contained in:
File diff suppressed because one or more lines are too long
2
soul-admin/dist/index.html
vendored
2
soul-admin/dist/index.html
vendored
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>管理后台 - Soul创业派对</title>
|
||||
<script type="module" crossorigin src="/assets/index-CmfGUxco.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-40AqCpw1.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-pe-kjH6p.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -92,11 +92,37 @@ export function CKBStatsTab({ onSwitchTab }: CKBStatsTabProps = {}) {
|
||||
try {
|
||||
const data = await get<{ success?: boolean; data?: MatchStats }>('/api/db/match-records?stats=true')
|
||||
if (data?.success && data.data) {
|
||||
setStats(data.data)
|
||||
let result = data.data
|
||||
// 后端 GORM bug 导致 uniqueUsers=0 时,前端自行计算
|
||||
if (result.totalMatches > 0 && (!result.uniqueUsers || result.uniqueUsers === 0)) {
|
||||
try {
|
||||
const allRec = await get<{ success?: boolean; records?: { userId: string }[]; total?: number }>(
|
||||
'/api/db/match-records?page=1&pageSize=200'
|
||||
)
|
||||
if (allRec?.success && allRec.records) {
|
||||
const userSet = new Set(allRec.records.map(r => r.userId).filter(Boolean))
|
||||
result = { ...result, uniqueUsers: userSet.size, totalMatches: allRec.total ?? result.totalMatches }
|
||||
}
|
||||
} catch { /* ignore fallback error */ }
|
||||
}
|
||||
setStats(result)
|
||||
} else {
|
||||
const fallback = await get<{ success?: boolean; total?: number }>('/api/db/match-records?page=1&pageSize=1')
|
||||
const fallback = await get<{ success?: boolean; records?: { userId: string; matchType: string; createdAt: string }[]; total?: number }>(
|
||||
'/api/db/match-records?page=1&pageSize=200'
|
||||
)
|
||||
if (fallback?.success) {
|
||||
setStats({ totalMatches: fallback.total ?? 0, todayMatches: 0, byType: [], uniqueUsers: 0 })
|
||||
const records = fallback.records || []
|
||||
const userSet = new Set(records.map(r => r.userId).filter(Boolean))
|
||||
const today = new Date().toISOString().slice(0, 10)
|
||||
const todayCount = records.filter(r => r.createdAt?.startsWith(today)).length
|
||||
const typeMap: Record<string, number> = {}
|
||||
records.forEach(r => { if (r.matchType) typeMap[r.matchType] = (typeMap[r.matchType] || 0) + 1 })
|
||||
setStats({
|
||||
totalMatches: fallback.total ?? records.length,
|
||||
todayMatches: todayCount,
|
||||
byType: Object.entries(typeMap).map(([matchType, count]) => ({ matchType, count })),
|
||||
uniqueUsers: userSet.size,
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (e) { console.error('加载统计失败:', e) }
|
||||
|
||||
Reference in New Issue
Block a user