From 1082d562519eb5911efadacce888cd7744dda3e7 Mon Sep 17 00:00:00 2001
From: liangping <18786721@qq.com>
Date: Thu, 25 Aug 2022 09:38:39 +0800
Subject: [PATCH] improve wallet change
---
src/layouts/components/Navbar.vue | 24 ++++++++++++++----------
src/views/Dashboard.vue | 19 ++++++++++---------
2 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/layouts/components/Navbar.vue b/src/layouts/components/Navbar.vue
index 1286bb4b..f24fc5e4 100644
--- a/src/layouts/components/Navbar.vue
+++ b/src/layouts/components/Navbar.vue
@@ -110,19 +110,23 @@
v-for="(item,k) in accounts"
:key="k"
:disabled="!item.address"
- :to="`/${selected_chain.chain_name}/account/${item.address.addr}`"
@click="updateDefaultWallet(item.wallet)"
>
-
{{ item.wallet }}
-
-
-
-
+
+ {{ item.wallet }}
+
+
+
+
+
+
+
+
{{ item.address ? formatAddr(item.address.addr) : `Not available on ${selected_chain.chain_name}` }}
diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue
index 9e6a017f..d7af52c8 100644
--- a/src/views/Dashboard.vue
+++ b/src/views/Dashboard.vue
@@ -248,6 +248,16 @@ export default {
computed: {
walletName() {
const key = this.$store?.state?.chains?.defaultWallet
+ if (key) {
+ const accounts = getLocalAccounts() || {}
+ const account = Object.entries(accounts)
+ .map(v => ({ wallet: v[0], address: v[1].address.find(x => x.chain === this.$store.state.chains.selected.chain_name) }))
+ .filter(v => v.address)
+ .find(x => x.wallet === key)
+ if (account) {
+ this.fetchAccount(account.address.addr)
+ }
+ }
return key || 'Wallet'
},
},
@@ -290,15 +300,6 @@ export default {
this.$http.getGovernanceListByStatus(2).then(res => {
this.proposals = res.proposals
})
-
- const accounts = getLocalAccounts() || {}
- const account = Object.entries(accounts)
- .map(v => ({ wallet: v[0], address: v[1].address.find(x => x.chain === this.$store.state.chains.selected.chain_name) }))
- .filter(v => v.address)
- .find(x => x.wallet === this.walletName)
- if (account) {
- this.fetchAccount(account.address.addr)
- }
},
methods: {
formatToken(tokens) {