feat: 更新环境配置,修改 API 地址,添加格式化金额功能,优化 RWA 交易视图

This commit is contained in:
2025-12-19 18:01:21 +07:00
parent 72775b4b37
commit 0bccd85744
11 changed files with 215 additions and 36 deletions

View File

@@ -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);
}