Files
Aether/frontend/src/features/usage/components/UsageModelTable.vue

86 lines
2.7 KiB
Vue
Raw Normal View History

2025-12-10 20:52:44 +08:00
<template>
<Card class="overflow-hidden">
<div class="px-3 py-2 border-b">
<h3 class="text-sm font-medium">
按模型分析
</h3>
2025-12-10 20:52:44 +08:00
</div>
<Table class="text-sm">
<TableHeader>
<TableRow>
<TableHead class="h-8 px-2">
模型
</TableHead>
<TableHead class="h-8 px-2 text-right">
请求数
</TableHead>
<TableHead class="h-8 px-2 text-right">
Tokens
</TableHead>
<TableHead class="h-8 px-2 text-right">
费用
</TableHead>
<TableHead class="h-8 px-2 text-right">
效率
</TableHead>
2025-12-10 20:52:44 +08:00
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-if="data.length === 0">
<TableCell
:colspan="5"
class="text-center py-6 text-muted-foreground px-2"
>
2025-12-10 20:52:44 +08:00
暂无模型统计数据
</TableCell>
</TableRow>
<TableRow
v-for="model in data"
:key="model.model"
>
2025-12-10 20:52:44 +08:00
<TableCell class="font-medium py-2 px-2">
{{ model.model.replace('claude-', '') }}
</TableCell>
<TableCell class="text-right py-2 px-2">
{{ model.request_count }}
</TableCell>
2025-12-10 20:52:44 +08:00
<TableCell class="text-right py-2 px-2">
<span>{{ formatTokens(model.total_tokens) }}</span>
</TableCell>
<TableCell class="text-right py-2 px-2">
<div class="flex flex-col items-end text-xs gap-0.5">
<span class="text-primary font-medium">{{ formatCurrency(model.total_cost) }}</span>
<span
v-if="isAdmin && model.actual_cost !== undefined"
class="text-muted-foreground text-[10px]"
>
2025-12-10 20:52:44 +08:00
{{ formatCurrency(model.actual_cost) }}
</span>
</div>
</TableCell>
<TableCell class="text-right text-muted-foreground py-2 px-2">
{{ model.costPerToken }}
</TableCell>
2025-12-10 20:52:44 +08:00
</TableRow>
</TableBody>
</Table>
</Card>
</template>
<script setup lang="ts">
import Card from '@/components/ui/card.vue'
import Table from '@/components/ui/table.vue'
import TableHeader from '@/components/ui/table-header.vue'
import TableBody from '@/components/ui/table-body.vue'
import TableRow from '@/components/ui/table-row.vue'
import TableHead from '@/components/ui/table-head.vue'
import TableCell from '@/components/ui/table-cell.vue'
import { formatTokens, formatCurrency } from '@/utils/format'
import type { EnhancedModelStatsItem } from '../types'
defineProps<{
data: EnhancedModelStatsItem[]
isAdmin: boolean
}>()
</script>