mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复PR #458中的totalCostLimit功能问题
主要修复: - 移除重复的totalUsageLimit字段,统一使用totalCostLimit - 删除auth.js中重复的总费用限制检查逻辑 - 删除admin.js中重复的totalCostLimit验证代码 - 更新所有前端组件,移除totalUsageLimit引用 功能改进: - 确保totalCostLimit作为永久累计费用限制正常工作 - 与dailyCostLimit(每日重置)功能互补 - 适用于预付费、一次性API Key场景 测试: - 删除有逻辑错误的test-total-usage-limit.js - 创建新的test-total-cost-limit.js验证功能正确性 - 所有测试通过,功能正常工作 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -190,11 +190,11 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="apiKey.totalUsageLimit > 0" class="space-y-2">
|
||||
<div v-if="apiKey.totalCostLimit > 0" class="space-y-2">
|
||||
<div class="flex items-center justify-between text-sm">
|
||||
<span class="text-gray-600 dark:text-gray-400">总费用限制</span>
|
||||
<span class="font-semibold text-gray-900 dark:text-gray-100">
|
||||
${{ apiKey.totalUsageLimit.toFixed(2) }}
|
||||
${{ apiKey.totalCostLimit.toFixed(2) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="h-2 w-full rounded-full bg-gray-200 dark:bg-gray-600">
|
||||
@@ -275,7 +275,7 @@ const totalTokens = computed(() => props.apiKey.usage?.total?.tokens || 0)
|
||||
const dailyTokens = computed(() => props.apiKey.usage?.daily?.tokens || 0)
|
||||
const totalCost = computed(() => props.apiKey.usage?.total?.cost || 0)
|
||||
const dailyCost = computed(() => props.apiKey.dailyCost || 0)
|
||||
const totalUsageLimit = computed(() => props.apiKey.totalUsageLimit || 0)
|
||||
const totalCostLimit = computed(() => props.apiKey.totalCostLimit || 0)
|
||||
const inputTokens = computed(() => props.apiKey.usage?.total?.inputTokens || 0)
|
||||
const outputTokens = computed(() => props.apiKey.usage?.total?.outputTokens || 0)
|
||||
const cacheCreateTokens = computed(() => props.apiKey.usage?.total?.cacheCreateTokens || 0)
|
||||
@@ -286,7 +286,7 @@ const tpm = computed(() => props.apiKey.usage?.averages?.tpm || 0)
|
||||
const hasLimits = computed(() => {
|
||||
return (
|
||||
props.apiKey.dailyCostLimit > 0 ||
|
||||
props.apiKey.totalUsageLimit > 0 ||
|
||||
props.apiKey.totalCostLimit > 0 ||
|
||||
props.apiKey.concurrencyLimit > 0 ||
|
||||
props.apiKey.rateLimitWindow > 0 ||
|
||||
props.apiKey.tokenLimit > 0
|
||||
@@ -299,8 +299,8 @@ const dailyCostPercentage = computed(() => {
|
||||
})
|
||||
|
||||
const totalUsagePercentage = computed(() => {
|
||||
if (!totalUsageLimit.value || totalUsageLimit.value === 0) return 0
|
||||
return (totalCost.value / totalUsageLimit.value) * 100
|
||||
if (!totalCostLimit.value || totalCostLimit.value === 0) return 0
|
||||
return (totalCost.value / totalCostLimit.value) * 100
|
||||
})
|
||||
|
||||
// 方法
|
||||
|
||||
Reference in New Issue
Block a user