Skip to content

Comments

fix: 修复状态栏错误显示 Free 套餐用量的问题#10

Merged
zcg merged 1 commit intobyebye-code:mainfrom
johnnyee:fix/issue-9-subscription-usage-display
Dec 10, 2025
Merged

fix: 修复状态栏错误显示 Free 套餐用量的问题#10
zcg merged 1 commit intobyebye-code:mainfrom
johnnyee:fix/issue-9-subscription-usage-display

Conversation

@johnnyee
Copy link
Contributor

@johnnyee johnnyee commented Dec 10, 2025

问题概述

状态栏始终显示 Free 套餐的用量($0/$20),即使 Plus 套餐正在被扣费。

根本原因

API 即使传入 model 参数,顶层返回的仍然是 Free 套餐数据。实际的套餐用量数据在 subscriptionEntityList 数组中。

解决方案

  1. 添加 SubscriptionEntity 结构体解析订阅列表
  2. 修改 calculate() 方法,从列表中找到正在扣费的套餐(currentCredits < creditLimit
  3. 使用该套餐的 creditLimitcurrentCredits 进行显示
  4. /api/usage/api/subscription 都传入 model 参数

修改的文件

文件 改动
src/api/mod.rs 添加 SubscriptionEntity 结构体,修复 calculate() 逻辑
src/api/client.rs get_usage() 添加 model 参数
src/api/cache.rs 更新 get_usage() 调用
src/core/segments/byebyecode_usage.rs 传入 model 到 API
src/core/segments/byebyecode_subscription.rs 传入 model 到 API

测试计划

  • 项目构建成功
  • 验证状态栏显示正确的 Plus 套餐用量(如 $4.53/$50
  • 确认 Free 套餐用户仍能正常显示

修复 #9

🤖 Generated with Claude Code

@johnnyee johnnyee changed the title fix: correctly display Plus subscription usage instead of Free fix: 修复状态栏错误显示 Free 套餐用量的问题 Dec 10, 2025
问题:状态栏始终显示 Free 套餐用量($0/$20),即使 Plus 套餐正在被扣费

根因:API 顶层返回 Free 套餐数据,实际数据在 subscriptionEntityList 中

修复:
- 添加 SubscriptionEntity 结构体解析订阅列表
- 从列表中找到正在扣费的套餐(currentCredits < creditLimit)
- 给 /api/usage 和 /api/subscription 传入 model 参数

修复 byebye-code#9

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@johnnyee johnnyee force-pushed the fix/issue-9-subscription-usage-display branch from b8dc450 to 0a650f8 Compare December 10, 2025 03:50
@zcg zcg merged commit 9a11f47 into byebye-code:main Dec 10, 2025
3 of 4 checks passed
johnnyee added a commit to johnnyee/byebyecode that referenced this pull request Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants