Commit 7e700931 authored by IanShaw027's avatar IanShaw027
Browse files

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

- 前端:移除进度条和限额文本,只显示 tier badge + 限流状态/倒计时
- 后端:token provider 自动保存 tier_id 到账号凭证
- 优化:tier 名称简化为 Free/Pro/Ultra
- 显示格式:[Free] 未限流 / [Pro] 限流 2m 35s
parent e4928177
......@@ -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)
......
......@@ -5,33 +5,15 @@
{{ 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'
]"
v-if="!isRateLimited"
class="text-xs text-gray-400 dark:text-gray-500"
>
{{ isRateLimited ? '100%' : '0%' }}
未限流
</span>
<!-- 倒计时 -->
<span
v-if="isRateLimited"
v-else
:class="[
'text-xs font-medium',
isUrgent
......@@ -39,19 +21,8 @@
: 'text-amber-600 dark:text-amber-400'
]"
>
⚠️ {{ resetCountdown }}
限流 {{ 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>
</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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment