fix(ui): 积分价格保留两位小数,不再四舍五入成整数
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
// Credit display helpers. Credits and model prices are stored server-side as
|
||||
// integer 积分 (points) — the single unit across the whole app. These helpers
|
||||
// only format for display; they do NOT convert units.
|
||||
/** Round to an integer 积分 value. */
|
||||
// 积分 (points) — the single unit across the whole app. Prices can be fractional
|
||||
// (0.11 积分/s), so keep two decimals instead of rounding them away. These
|
||||
// helpers only format for display; they do NOT convert units.
|
||||
/** Round to a 积分 value with at most 2 decimals. */
|
||||
export function points(value) {
|
||||
return Math.round(Number(value || 0))
|
||||
return Math.round(Number(value || 0) * 100) / 100
|
||||
}
|
||||
|
||||
/** "<n> 积分" label with thousands separators. */
|
||||
export function pointsLabel(value) {
|
||||
return points(value).toLocaleString('en-US') + ' 积分'
|
||||
return points(value).toLocaleString('en-US', { maximumFractionDigits: 2 }) + ' 积分'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user