fix: 当 /api/usage 返回无效数据时,fallback 到 /api/subscription #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
/api/usage返回无效数据(creditLimit=null, subscriptionEntityList=null)时,自动 fallback 到/api/subscription获取用量数据问题原因
88code 的
/api/usage接口返回的关键字段全是 null,导致状态栏无法正确显示用量。解决方案
采用双重保障策略:优先使用原接口,失败时 fallback
is_valid()方法判断 usage 数据是否有效SubscriptionPlan结构体解析嵌套的creditLimitfrom_subscriptions()方法从订阅数据构造等价的 UsageDataget_usage()中加入 fallback 逻辑fetch_usage_with_cache()传入正确的subscription_url优势
Test plan
Closes #26
🤖 Generated with Claude Code