refactor(gemini): 简化用量窗口显示为等级+限流状态

- 前端:移除进度条和限额文本,只显示 tier badge + 限流状态/倒计时
- 后端:token provider 自动保存 tier_id 到账号凭证
- 优化:tier 名称简化为 Free/Pro/Ultra
- 显示格式:[Free] 未限流 / [Pro] 限流 2m 35s
This commit is contained in:
IanShaw027
2026-01-01 00:40:51 +08:00
parent e49281774d
commit 7e70093117
2 changed files with 21 additions and 63 deletions

View File

@@ -118,6 +118,7 @@ func (p *GeminiTokenProvider) GetAccessToken(ctx context.Context, account *Accou
return accessToken, nil
}
detected = strings.TrimSpace(detected)
tierID = strings.TrimSpace(tierID)
if detected != "" {
if account.Credentials == nil {
account.Credentials = make(map[string]any)

View File

@@ -5,53 +5,24 @@
{{ tierLabel }}
</span>
<!-- 额文本 -->
<span class="text-xs text-gray-500 dark:text-gray-400">{{ quotaText }}</span>
<!-- 二元进度条 -->
<div class="group/progress relative flex items-center gap-1">
<div class="h-2 w-20 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700">
<div
:class="[
'h-full transition-all',
isRateLimited ? 'bg-red-500' : 'bg-gray-300 dark:bg-gray-600'
]"
:style="{ width: isRateLimited ? '100%' : '0%' }"
></div>
</div>
<span
:class="[
'text-xs font-medium',
isRateLimited ? 'text-red-600 dark:text-red-400' : 'text-gray-400 dark:text-gray-500'
]"
>
{{ isRateLimited ? '100%' : '0%' }}
</span>
<!-- 倒计时 -->
<span
v-if="isRateLimited"
:class="[
'text-xs font-medium',
isUrgent
? 'text-red-600 dark:text-red-400 animate-pulse'
: 'text-amber-600 dark:text-amber-400'
]"
>
{{ resetCountdown }}
</span>
<!-- Tooltip -->
<div
class="pointer-events-none absolute -top-10 left-0 z-10 hidden whitespace-nowrap rounded bg-gray-900 px-2 py-1 text-xs text-white shadow-lg group-hover/progress:block dark:bg-gray-700"
>
无法提供实时额度
<div
class="absolute left-4 top-full border-4 border-transparent border-t-gray-900 dark:border-t-gray-700"
></div>
</div>
</div>
<!-- 流状态 -->
<span
v-if="!isRateLimited"
class="text-xs text-gray-400 dark:text-gray-500"
>
未限流
</span>
<span
v-else
:class="[
'text-xs font-medium',
isUrgent
? 'text-red-600 dark:text-red-400 animate-pulse'
: 'text-amber-600 dark:text-amber-400'
]"
>
限流 {{ resetCountdown }}
</span>
</div>
</template>
@@ -85,8 +56,8 @@ const tierLabel = computed(() => {
const creds = props.account.credentials as GeminiCredentials | undefined
const tierMap: Record<string, string> = {
LEGACY: 'Free',
PRO: 'Standard',
ULTRA: 'Enterprise'
PRO: 'Pro',
ULTRA: 'Ultra'
}
return tierMap[creds?.tier_id || ''] || 'Unknown'
}
@@ -110,20 +81,6 @@ const tierBadgeClass = computed(() => {
)
})
// 限额文本
const quotaText = computed(() => {
if (isCodeAssist.value) {
const creds = props.account.credentials as GeminiCredentials | undefined
const limitMap: Record<string, string> = {
LEGACY: '1000/day, 60/min',
PRO: '1500/day, 120/min',
ULTRA: '5000/day, 300/min'
}
return limitMap[creds?.tier_id || ''] || '-'
}
return 'RPM/RPD limits'
})
// 是否限流
const isRateLimited = computed(() => {
if (!props.account.rate_limit_reset_at) return false