feat(usage): 统计表格新增输入/输出与缓存创建token细分展示

- 后端接口(admin/user_me/query)新增 output_tokens、cache_creation_tokens、total_input_context 字段返回
- 前端统计表格(模型/提供商/API格式)合并 Tokens 列为"输入/输出"+"缓存读取/创建"两行紧凑布局
- 合并"缓存Token"和"缓存命中率"为单一"命中率"列,减少表格宽度
- 修正 UsageRecordsTable 缩进及模板格式
This commit is contained in:
fawney19
2026-03-14 16:11:56 +08:00
parent aafd332198
commit 751a4d9111
11 changed files with 268 additions and 186 deletions
@@ -16,16 +16,16 @@
请求数
</TableHead>
<TableHead class="h-8 px-2 text-right">
Tokens
<div class="flex flex-col text-xs gap-0.5">
<span>输入/输出</span>
<span class="text-muted-foreground font-normal">缓存</span>
</div>
</TableHead>
<TableHead class="h-8 px-2 text-right">
费用
</TableHead>
<TableHead class="h-8 px-2 text-right">
缓存Token
</TableHead>
<TableHead class="h-8 px-2 text-right">
缓存命中率
命中率
</TableHead>
<TableHead class="h-8 px-2 text-right">
成功率
@@ -38,7 +38,7 @@
<TableBody>
<TableRow v-if="data.length === 0">
<TableCell
:colspan="8"
:colspan="7"
class="text-center py-6 text-muted-foreground px-2"
>
暂无提供商统计数据
@@ -55,7 +55,10 @@
{{ provider.requests }}
</TableCell>
<TableCell class="text-right py-2 px-2">
<span>{{ formatTokens(provider.totalTokens) }}</span>
<div class="flex flex-col items-end text-xs gap-0.5">
<span>{{ formatTokens(provider.totalInputContext || 0) }} / {{ formatTokens(provider.outputTokens || 0) }}</span>
<span class="text-muted-foreground">{{ formatTokens(provider.cacheReadTokens || 0) }} / {{ formatTokens(provider.cacheCreationTokens || 0) }}</span>
</div>
</TableCell>
<TableCell class="text-right py-2 px-2">
<div class="flex flex-col items-end text-xs gap-0.5">
@@ -69,10 +72,7 @@
</div>
</TableCell>
<TableCell class="text-right py-2 px-2">
{{ formatTokens(provider.cacheReadTokens || 0) }}
</TableCell>
<TableCell class="text-right py-2 px-2 text-muted-foreground">
{{ formatHitRate(provider.cacheHitRate) }}
<span>{{ formatHitRate(provider.cacheHitRate) }}</span>
</TableCell>
<TableCell class="text-right py-2 px-2">
<span :class="getSuccessRateClass(provider.successRate)">{{ provider.successRate }}%</span>
@@ -108,5 +108,4 @@ function getSuccessRateClass(rate: number): string {
if (rate < 90) return 'text-destructive'
return '' // 默认颜色
}
</script>