mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
feat(admin): 用量记录页新增"用户 Token 排行"面板
- 在 /admin/usage 新增按用户聚合的 Token 排行表(输入/输出/缓存/总 Token、请求数、费用) - 支持按列排序、邮箱搜索、Top N (20/50/100/200),点击行下钻到该用户 - 复用现有筛选(用户/时间/模型/分组等)与既有 KPI 卡片、逐条日志 - 后端对 /admin/dashboard/user-breakdown 做加法扩展(向后兼容): - UserBreakdownItem 增加 input_tokens/output_tokens/cache_tokens - 新增 sort_by(白名单排序,防注入,缺省仍按 actual_cost) - 新增 sort_by 转发单元测试;更新 UsageView.spec 稳定桩 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
64fdc11ec4
commit
b062b36646
@@ -675,6 +675,9 @@ func (h *DashboardHandler) GetUserBreakdown(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// sort_by 由 repo 层 allowlist 校验;非法值静默回退默认排序(actual_cost)。
|
||||
dim.SortBy = strings.TrimSpace(c.Query("sort_by"))
|
||||
|
||||
limit := 50
|
||||
if v := c.Query("limit"); v != "" {
|
||||
if n, err := strconv.Atoi(v); err == nil && n > 0 && n <= 200 {
|
||||
|
||||
Reference in New Issue
Block a user