feat(ui): 添加 Big.js 格式化工具,优化表格数字精度展示

This commit is contained in:
2026-04-27 22:32:35 +08:00
parent eba5a68495
commit 978d8a591e
4 changed files with 39 additions and 5 deletions
+16
View File
@@ -0,0 +1,16 @@
import Big from 'big.js';
export function formatAmount(value: string): string {
return new Big(value).toFixed(2);
}
export function formatQuantity(value: string, assetType: string): string {
switch (assetType) {
case 'STOCK':
return new Big(value).round(0).toString();
case 'CRYPTO':
return new Big(value).round(8).toString();
default:
return new Big(value).toFixed(2);
}
}