feat: 更新环境配置,修改 API 地址,添加格式化金额功能,优化 RWA 交易视图
This commit is contained in:
@@ -14,3 +14,31 @@ export function timeToLocal(originalTime: number) {
|
||||
const d = new Date(originalTime * 1000);
|
||||
return Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()) / 1000;
|
||||
}
|
||||
|
||||
export function formatAmount(amount: MaybeRefOrGetter<number | string | null | undefined>): string {
|
||||
const value = toValue(amount);
|
||||
if (Number.isNaN(Number(value))) {
|
||||
return "0";
|
||||
}
|
||||
|
||||
const num = Number(value);
|
||||
|
||||
// 不超过1万,原样显示
|
||||
if (num < 10000) {
|
||||
return String(num);
|
||||
}
|
||||
|
||||
// 1亿以上,显示为xx亿
|
||||
if (num >= 100000000) {
|
||||
const yi = (num / 100000000).toFixed(1);
|
||||
return yi.endsWith(".0") ? `${Number.parseInt(yi)}亿` : `${yi}亿`;
|
||||
}
|
||||
|
||||
// 1万到1亿,显示为xx万
|
||||
if (num >= 10000) {
|
||||
const wan = (num / 10000).toFixed(1);
|
||||
return wan.endsWith(".0") ? `${Number.parseInt(wan)}万` : `${wan}万`;
|
||||
}
|
||||
|
||||
return String(num);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user