fix: 优化登录流程和余额查询逻辑

- 添加 fetchBalanceWithToken 支持登录时直接传入 token 查询余额
- AuthProvider 会话加载改为同步方式避免时序问题
- 添加调试日志便于排查问题
This commit is contained in:
XiaoFeng
2026-01-13 20:06:42 +08:00
parent 5753e120ba
commit 7d1b8f7e26
4 changed files with 35 additions and 6 deletions

View File

@ -8,7 +8,7 @@ import { URL } from 'url';
import * as vscode from 'vscode';
import { getStrangeLoopApiUrl, getConfig } from '../config/settings';
import type { UserInfoResponse, MembershipResponse, MultiMembershipVO, MembershipItemVO } from '../types/api';
import { fetchBalance, getCachedBalance } from './creditsService';
import { fetchBalanceWithToken, getCachedBalance } from './creditsService';
/**
* HTTP 请求选项
@ -230,7 +230,7 @@ export async function onTokenReceived(token: string): Promise<UserInfo | null> {
const [userInfo, membershipInfo, credits] = await Promise.all([
getUserInfo(token),
getMembershipInfo(token),
fetchBalance()
fetchBalanceWithToken(token)
]);
if (!userInfo) {