feat(ui): 添加 Big.js 格式化工具,优化表格数字精度展示
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user