"frontend/src/vscode:/vscode.git/clone" did not exist on "aab44f9fc8e9738898cd113e5af31c8c1c6183f1"
Commit 0a4e0edc authored by song's avatar song
Browse files

fix(Antigravity): 配额刷新时自动补充缺失的 project_id

旧账户可能没有 project_id,在刷新配额时自动生成并保存。
parent fa48cf27
......@@ -145,16 +145,25 @@ func (r *AntigravityQuotaRefresher) refreshAccountQuota(ctx context.Context, acc
client := antigravity.NewClient(proxyURL)
// 获取账户类型(tier)
// 获取账户类型(tier)和 project_id
loadResp, _ := client.LoadCodeAssist(ctx, accessToken)
if loadResp != nil {
r.updateAccountTier(account, loadResp)
// 尝试从 API 获取 project_id
if projectID == "" && loadResp.CloudAICompanionProject != "" {
projectID = loadResp.CloudAICompanionProject
account.Credentials["project_id"] = projectID
}
}
// 调用 API 获取配额(需要 projectID)
// 如果仍然没有 project_id,随机生成一个并保存
if projectID == "" {
return r.accountRepo.Update(ctx, account) // 没有 projectID,只更新 tier
projectID = antigravity.GenerateMockProjectID()
account.Credentials["project_id"] = projectID
log.Printf("[AntigravityQuotaRefresher] 为账户 %d 生成随机 project_id: %s", account.ID, projectID)
}
// 调用 API 获取配额
modelsResp, err := client.FetchAvailableModels(ctx, accessToken, projectID)
if err != nil {
return err
......
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