diff --git a/frontend/src/api/dashboard.ts b/frontend/src/api/dashboard.ts
index f4f3ed7..bcc00b9 100644
--- a/frontend/src/api/dashboard.ts
+++ b/frontend/src/api/dashboard.ts
@@ -87,6 +87,8 @@ export interface DashboardStatsResponse {
cache_stats?: CacheStats
users?: UserStats
token_breakdown?: TokenBreakdown
+ // 普通用户专用字段
+ monthly_cost?: number
}
export interface RecentRequestsResponse {
diff --git a/frontend/src/views/shared/Dashboard.vue b/frontend/src/views/shared/Dashboard.vue
index 9449872..b1eee04 100644
--- a/frontend/src/views/shared/Dashboard.vue
+++ b/frontend/src/views/shared/Dashboard.vue
@@ -162,14 +162,14 @@
-
+
- 本月缓存使用
+ 本月统计
-
-
+
+
-
+
-
+
-
+
- 总Token
+ 本月费用
- {{ formatTokens((tokenBreakdown.input || 0) + (tokenBreakdown.output || 0)) }}
-
-
- 输入 {{ formatTokens(tokenBreakdown.input || 0) }} / 输出 {{ formatTokens(tokenBreakdown.output || 0) }}
+ {{ formatCurrency(userMonthlyCost) }}
@@ -831,6 +842,12 @@ const cacheStats = ref<{
total_cache_tokens: number
} | null>(null)
+const userMonthlyCost = ref(null)
+
+const hasCacheData = computed(() =>
+ cacheStats.value && cacheStats.value.total_cache_tokens > 0
+)
+
const tokenBreakdown = ref<{
input: number
output: number
@@ -1086,6 +1103,7 @@ async function loadDashboardData() {
} else {
if (statsData.cache_stats) cacheStats.value = statsData.cache_stats
if (statsData.token_breakdown) tokenBreakdown.value = statsData.token_breakdown
+ if (statsData.monthly_cost !== undefined) userMonthlyCost.value = statsData.monthly_cost
}
} finally {
loading.value = false
diff --git a/src/api/dashboard/routes.py b/src/api/dashboard/routes.py
index 006cb1d..e091c0a 100644
--- a/src/api/dashboard/routes.py
+++ b/src/api/dashboard/routes.py
@@ -610,9 +610,15 @@ class UserDashboardStatsAdapter(DashboardAdapter):
"icon": "TrendingUp",
},
{
- "name": "本月费用",
- "value": f"${user_cost:.2f}",
- "icon": "DollarSign",
+ "name": "总Token",
+ "value": format_tokens(
+ all_time_input_tokens
+ + all_time_output_tokens
+ + all_time_cache_creation
+ + all_time_cache_read
+ ),
+ "subValue": f"输入 {format_tokens(all_time_input_tokens)} / 输出 {format_tokens(all_time_output_tokens)}",
+ "icon": "Hash",
},
],
"today": {
@@ -636,6 +642,8 @@ class UserDashboardStatsAdapter(DashboardAdapter):
"cache_hit_rate": cache_hit_rate,
"total_cache_tokens": cache_creation_tokens + cache_read_tokens,
},
+ # 本月费用(用于下方缓存区域显示)
+ "monthly_cost": float(user_cost),
}