"backend/internal/vscode:/vscode.git/clone" did not exist on "12d03e4030982c5356b6d23379a2de63378f00d1"
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 ...@@ -118,6 +118,7 @@ func (p *GeminiTokenProvider) GetAccessToken(ctx context.Context, account *Accou
return accessToken, nil return accessToken, nil
} }
detected = strings.TrimSpace(detected) detected = strings.TrimSpace(detected)
tierID = strings.TrimSpace(tierID)
if detected != "" { if detected != "" {
if account.Credentials == nil { if account.Credentials == nil {
account.Credentials = make(map[string]any) account.Credentials = make(map[string]any)
......
...@@ -5,53 +5,24 @@ ...@@ -5,53 +5,24 @@
{{ tierLabel }} {{ tierLabel }}
</span> </span>
<!-- 限额文本 --> <!-- 限流状态 -->
<span class="text-xs text-gray-500 dark:text-gray-400">{{ quotaText }}</span> <span
v-if="!isRateLimited"
<!-- 二元进度条 --> class="text-xs text-gray-400 dark:text-gray-500"
<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 </span>
:class="[ <span
'h-full transition-all', v-else
isRateLimited ? 'bg-red-500' : 'bg-gray-300 dark:bg-gray-600' :class="[
]" 'text-xs font-medium',
:style="{ width: isRateLimited ? '100%' : '0%' }" isUrgent
></div> ? 'text-red-600 dark:text-red-400 animate-pulse'
</div> : 'text-amber-600 dark:text-amber-400'
]"
<span >
:class="[ 限流 {{ resetCountdown }}
'text-xs font-medium', </span>
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>
</div> </div>
</template> </template>
...@@ -85,8 +56,8 @@ const tierLabel = computed(() => { ...@@ -85,8 +56,8 @@ const tierLabel = computed(() => {
const creds = props.account.credentials as GeminiCredentials | undefined const creds = props.account.credentials as GeminiCredentials | undefined
const tierMap: Record<string, string> = { const tierMap: Record<string, string> = {
LEGACY: 'Free', LEGACY: 'Free',
PRO: 'Standard', PRO: 'Pro',
ULTRA: 'Enterprise' ULTRA: 'Ultra'
} }
return tierMap[creds?.tier_id || ''] || 'Unknown' return tierMap[creds?.tier_id || ''] || 'Unknown'
} }
...@@ -110,20 +81,6 @@ const tierBadgeClass = computed(() => { ...@@ -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(() => { const isRateLimited = computed(() => {
if (!props.account.rate_limit_reset_at) return false 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