Skip to content

fix: 修复余额显示时只切换了单位未切换数值 - #5296

Merged
t0ng7u merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/27fe9a3a82f51bac2b7645213e3b1480cb7f14f2
Jun 3, 2026
Merged

fix: 修复余额显示时只切换了单位未切换数值#5296
t0ng7u merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/27fe9a3a82f51bac2b7645213e3b1480cb7f14f2

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jun 3, 2026

Copy link
Copy Markdown
Member

⚠️ 提交说明 / PR Notice

classic的余额显示, 只切换了单位,未切换数值
default的余额显示, 可以正常切换单位和数值

📝 变更描述 / Description

同步了default的余额代币转换逻辑

📸 运行证明 / Proof of Work

实际余额为 1378.19元
修复前: (显示成了cny单位, $数值)
image

修复后:显示正确货币单位和数值
image

Summary by CodeRabbit

  • Refactor
    • Updated currency conversion and display logic to dynamically calculate display values based on exchange rates and currency configuration, replacing hardcoded currency handling.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f1014d6-baf9-4adb-9daf-32c4db1be0c8

📥 Commits

Reviewing files that changed from the base of the PR and between b0ac042 and 580ad97.

📒 Files selected for processing (1)
  • web/classic/src/helpers/render.jsx

Walkthrough

The renderQuotaWithAmount function in web/classic/src/helpers/render.jsx was refactored to centralize currency display logic via getCurrencyConfig(). Internal USD amounts are now converted to display currency using the configured symbol and exchange rate, with special handling for token types and non-finite values.

Changes

Currency Rendering Logic Consolidation

Layer / File(s) Summary
Currency config-driven quota display
web/classic/src/helpers/render.jsx
renderQuotaWithAmount now derives currency settings (symbol, rate, type) from getCurrencyConfig() and applies unified rate-based conversion for non-token amounts, replacing hardcoded USD/CNY/CUSTOM branching and $ fallback logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • QuantumNous/new-api#2360: Both PRs update the price/quota rendering helper to use the current currency configuration (symbol/rate) instead of hardcoded or raw currency formatting—main PR in renderQuotaWithAmount, retrieved PR in renderPriceSimpleCore.
  • QuantumNous/new-api#3233: Both PRs modify renderQuotaWithAmount(amount) in render.jsx to change how non-TOKENS balances are formatted/rounded (main PR via getCurrencyConfig() display conversion, retrieved PR via numeric parsing + toFixed(2) formatting).

Suggested reviewers

  • seefs001

Poem

🐰 The quota now speaks in every tongue,
getCurrencyConfig() makes conversions sung,
No hardcoded dollars left to haunt,
Exchange rates flow where they should flaunt,
TOKENS still reign, the rate multiplies true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 translates to 'fix: Fixed balance display only switching units without switching values'. It directly addresses the main issue: the classic version only switched currency units but not the numeric values. This precisely matches the primary change in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@t0ng7u
t0ng7u merged commit 00d23ab into QuantumNous:main Jun 3, 2026
2 checks passed
OuYang-HX pushed a commit to OuYang-HX/new-api that referenced this pull request Jun 13, 2026
Merge pull request QuantumNous#5296 from feitianbubu/pr/27fe9a3a82f51bac2b7645213e3b1480cb7f14f2
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
Merge pull request QuantumNous#5296 from feitianbubu/pr/27fe9a3a82f51bac2b7645213e3b1480cb7f14f2
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
Merge pull request QuantumNous#5296 from feitianbubu/pr/27fe9a3a82f51bac2b7645213e3b1480cb7f14f2
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