Skip to content

修复钱包页面刷新时显示错误余额数据的问题#2749

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
wans10:main
Jan 26, 2026
Merged

修复钱包页面刷新时显示错误余额数据的问题#2749
seefs001 merged 1 commit into
QuantumNous:mainfrom
wans10:main

Conversation

@wans10
Copy link
Copy Markdown
Contributor

@wans10 wans10 commented Jan 26, 2026

问题现象
在钱包管理页面刷新时,账户的统计数据(当前余额、历史消耗、请求次数)会短暂显示错误的数值或 NaN,随后才恢复正常。

原因分析
TopUp 组件的 useEffect 逻辑中存在优化判断:当检测到 userState?.user?.id 存在时会跳过 getUserQuota() 的 API 调用。 然而,页面刷新时 PageLayout 会优先从 localStorage 加载缓存的用户信息,这份缓存数据往往是过期的或缺少 quota 等动态字段,导致页面渲染了错误的数据。

解决方案
移除了 useEffect 中的条件判断,强制组件在挂载时始终调用 getUserQuota(),确保无论本地缓存状态如何,都能获取并显示最新的用户配额信息。

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced the top-up feature to reliably refresh user quota and balance information on component load, ensuring users always see current and accurate account details.

✏️ Tip: You can customize this high-level summary in your review settings.

- 移除用户ID检查条件,始终获取最新用户数据
- 确保余额等统计信息准确性
- 解决用户状态更新不及时的问题
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 26, 2026

Walkthrough

The top-up component's mount useEffect was modified to unconditionally fetch the latest user quota via getUserQuota(). Previously, it only fetched when user.id was absent. The change ensures up-to-date quota information loads every time the component mounts, with a Chinese comment noting the unconditional refresh requirement.

Changes

Cohort / File(s) Summary
Top-up component useEffect
web/src/components/topup/index.jsx
Modified mount effect to unconditionally call getUserQuota() instead of conditionally fetching only when user absent. Added explanatory Chinese comment.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • seefs001

Poem

🐰 Fresh quota awaits each hop and bound,
No more waiting—unconditional sound!
The carrot data flows without delay,
Always fresh from mount to day! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title in Chinese describes fixing incorrect balance data display when refreshing the wallet page, which directly corresponds to the main change: making useEffect unconditionally fetch the latest user quota.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001 seefs001 merged commit 35c055e into QuantumNous:main Jan 26, 2026
1 check passed
dreamlx pushed a commit to dreamlx/new-api that referenced this pull request Feb 1, 2026
主要更新:
- feat: 磁盘请求体缓存 (QuantumNous#2780)
- feat: OpenAI Response API /v1/response/compact (QuantumNous#2644)
- feat: 渠道亲和性 (Channel Affinity) (QuantumNous#2669)
- feat: Codex渠道支持 (QuantumNous#2652)
- feat: Claude/Grok refusal reason显示
- feat: 性能监控和GC控制API
- fix: 用户配额获取逻辑 (QuantumNous#2749)
- fix: Gemini多工具调用索引问题
- fix: 错误时仍本地计费

冲突解决:
- README.md: 保留中文版本
- go.mod: 采用上游较新版本

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
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