Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
a9e5fc85
Commit
a9e5fc85
authored
Apr 01, 2026
by
erio
Browse files
fix(ui): floating point precision in perTokenToMTok conversion
parent
9b213115
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/admin/channel/types.ts
View file @
a9e5fc85
...
...
@@ -42,7 +42,8 @@ export function mTokToPerToken(val: number | string | null | undefined): number
/** 后端存储值(per-token) → 前端显示值($/MTok) */
export
function
perTokenToMTok
(
val
:
number
|
null
|
undefined
):
number
|
null
{
if
(
val
===
null
||
val
===
undefined
)
return
null
return
val
*
MTOK
// toPrecision(10) 消除 IEEE 754 浮点乘法精度误差,如 5e-8 * 1e6 = 0.04999...96 → 0.05
return
parseFloat
((
val
*
MTOK
).
toPrecision
(
10
))
}
export
function
apiIntervalsToForm
(
intervals
:
PricingInterval
[]):
IntervalFormEntry
[]
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment