refactor(antigravity): 统一额度刷新机制与 Claude 一致
将 Antigravity 的额度刷新从后台定时刷新改为按需获取模式,与 Claude 统一: - 删除 AntigravityQuotaRefresher 后台服务 - 新增 QuotaFetcher 接口和 AntigravityQuotaFetcher 实现 - 前端改为调用 usage API 获取额度,支持 loading/error 状态 - 统一使用内存缓存(10 分钟 TTL)
This commit is contained in:
19
backend/internal/service/quota_fetcher.go
Normal file
19
backend/internal/service/quota_fetcher.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// QuotaFetcher 额度获取接口,各平台实现此接口
|
||||
type QuotaFetcher interface {
|
||||
// CanFetch 检查是否可以获取此账户的额度
|
||||
CanFetch(account *Account) bool
|
||||
// FetchQuota 获取账户额度信息
|
||||
FetchQuota(ctx context.Context, account *Account, proxyURL string) (*QuotaResult, error)
|
||||
}
|
||||
|
||||
// QuotaResult 额度获取结果
|
||||
type QuotaResult struct {
|
||||
UsageInfo *UsageInfo // 转换后的使用信息
|
||||
Raw map[string]any // 原始响应,可存入 account.Extra
|
||||
}
|
||||
Reference in New Issue
Block a user