Skip to content

fix(dashboard): 统一消费金额格式,避免小额显示过长#196

Merged
g1331 merged 1 commit into
masterfrom
fix/dashboard-cost-format
May 30, 2026
Merged

fix(dashboard): 统一消费金额格式,避免小额显示过长#196
g1331 merged 1 commit into
masterfrom
fix/dashboard-cost-format

Conversation

@g1331
Copy link
Copy Markdown
Owner

@g1331 g1331 commented May 30, 2026

Summary

统一仪表盘消费金额的展示格式,修复「今日消费」卡片在小额场景下显示过长的问题(例如 $0.006599 占用九个字符,明显长于同排其它卡片)。

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Refactoring (code improvement without changing functionality)
  • Tests (adding or updating tests)

Changes

  • formatCost 提取到 src/components/dashboard/chart-theme.ts,仪表盘统计卡片与排行榜共用同一份实现,消除两处重复。
  • 调整金额格式:小于一分从六位小数改为四位小数;常规金额改为两位小数;千级与百万级分别用 K / M 缩写。
  • 同步修复排行榜「消费金额」列里相同的小额六位小数缺陷。
  • stats-cardsleaderboard-section 补充金额格式化单元测试。

显示效果对照:$0.006599$0.0066$16.9599$16.96$1234.5000$1.23K$2500000.0000$2.50M

Test Plan

  • Local tests pass (pnpm test:run),tests/components/dashboard/ 共 81 项通过
  • Type check passes (pnpm exec tsc --noEmit)
  • Lint passes,改动文件 ESLint 通过
  • Manual testing completed

Checklist

  • Code follows the project's coding standards
  • Tests have been added where necessary
  • Documentation has been updated (if applicable)
  • Changes do not introduce security vulnerabilities
  • Commit messages follow conventions

Additional Notes

本次仅改动 dashboard 三个源文件与两个测试文件,不涉及接口、数据格式或持久化变更。

仪表盘今日消费卡片与排行榜消费列共用一份 formatCost:小于一分从六位小数改为四位小数,常规金额改为两位小数,千/百万级用 K/M 缩写。将 formatCost 提取到 chart-theme.ts 复用,消除两处重复实现,并补充对应单元测试。
@g1331 g1331 merged commit b5ee1b3 into master May 30, 2026
12 checks passed
@g1331 g1331 deleted the fix/dashboard-cost-format branch May 30, 2026 07:46
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.

1 participant