From 8c7e2f662076f09ee986cc568f8c8d6981129d53 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 12 Oct 2021 20:25:53 +0800 Subject: [PATCH] optimize UI --- public/index.html | 6 +++--- src/libs/data/data.js | 16 +++++++--------- src/views/WalletAccounts.vue | 34 +++++++++------------------------- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/public/index.html b/public/index.html index 63d5b490..6c5f0141 100644 --- a/public/index.html +++ b/public/index.html @@ -6,9 +6,9 @@ - + - +
diff --git a/src/libs/data/data.js b/src/libs/data/data.js index d0f86aa4..055d6ce9 100644 --- a/src/libs/data/data.js +++ b/src/libs/data/data.js @@ -269,16 +269,14 @@ export function formatTokenDenom(tokenDenom) { } export function formatTokenAmount(tokenAmount, fraction = 2, denom = 'uatom') { - let decimals = 1000000n + let amount if (denom.startsWith('rowan')) { - decimals = 1000000000000000000n + // eslint-disable-next-line no-undef + amount = Number(BigInt(Number(tokenAmount)) / 1000000000000000000n) + // } + } else { + amount = Number(tokenAmount) / 1000000 } - let ta = tokenAmount - if (typeof tokenAmount === 'string' && tokenAmount.indexOf('.') > 0) { - ta = tokenAmount.substring(0, tokenAmount.indexOf('.')) - } - // eslint-disable-next-line no-undef - const amount = Number(BigInt(ta) / decimals) if (amount > 10) { return parseFloat(amount.toFixed(fraction)) } @@ -287,7 +285,7 @@ export function formatTokenAmount(tokenAmount, fraction = 2, denom = 'uatom') { export function formatToken(token, IBCDenom = {}) { if (token) { - return `${formatTokenAmount(token.amount, 2, token.denom)} ${formatTokenDenom(IBCDenom[token.denom] || token.denom)}` + return `${formatTokenAmount(token.amount, 0, token.denom)} ${formatTokenDenom(IBCDenom[token.denom] || token.denom)}` } return token } diff --git a/src/views/WalletAccounts.vue b/src/views/WalletAccounts.vue index bd5e5ca8..dbdd8d19 100644 --- a/src/views/WalletAccounts.vue +++ b/src/views/WalletAccounts.vue @@ -170,18 +170,10 @@ :key="i" class="d-flex justify-content-between align-items-center" > -
- - - +
{{ formatDenom(b.denom) }} -
- - - +
{{ formatDenom(b.denom) }}