fix(usage): 移动端缓存 token 拆分为读/写两列展示

cache_read 与 cache_creation 原本被合并为单值,现分别显示并补充测试
This commit is contained in:
fawney19
2026-04-25 09:53:32 +08:00
parent e5bbc797e0
commit 1761921670
3 changed files with 28 additions and 6 deletions
@@ -569,9 +569,9 @@
<span>{{ formatTokens(record.output_tokens || 0) }}</span>
</div>
<div class="flex items-center gap-1 text-muted-foreground">
<span :class="hasPositiveTokens(getRecordCacheTokens(record)) ? 'text-foreground/70' : ''">{{ formatOptionalTokens(getRecordCacheTokens(record)) }}</span>
<span :class="hasPositiveTokens(getRecordCacheReadTokens(record)) ? 'text-foreground/70' : ''">{{ formatOptionalTokens(getRecordCacheReadTokens(record)) }}</span>
<span>/</span>
<span>-</span>
<span :class="hasPositiveTokens(getRecordCacheCreationTokens(record)) ? 'text-foreground/70' : ''">{{ formatOptionalTokens(getRecordCacheCreationTokens(record)) }}</span>
</div>
</div>
</TableCell>
@@ -689,7 +689,7 @@ import {
import { RefreshCcw, Search } from 'lucide-vue-next'
import { formatTokens, formatCurrency } from '@/utils/format'
import { formatDateTime } from '../composables'
import { getCacheCreationTokens, getEffectiveInputTokens } from '../token-normalization'
import { getCacheCreationTokens, getCacheReadTokens, getEffectiveInputTokens } from '../token-normalization'
import {
formatUsageStreamLabel,
isUsageRecordFailed,
@@ -825,8 +825,12 @@ function getRecordEffectiveInputTokens(record: UsageRecord): number {
return getEffectiveInputTokens(record)
}
function getRecordCacheTokens(record: UsageRecord): number {
return getCacheCreationTokens(record) + (record.cache_read_input_tokens || 0)
function getRecordCacheReadTokens(record: UsageRecord): number {
return getCacheReadTokens(record)
}
function getRecordCacheCreationTokens(record: UsageRecord): number {
return getCacheCreationTokens(record)
}
function hasPositiveTokens(value: number | null | undefined): boolean {