improve wallet change

This commit is contained in:
liangping 2022-08-25 09:38:39 +08:00
parent e83e38355f
commit 1082d56251
2 changed files with 24 additions and 19 deletions

View File

@ -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)"
>
<div class="d-flex flex-column">
<span class="font-weight-bolder">{{ item.wallet }}
<b-avatar
v-if="item.wallet===walletName"
variant="success"
size="sm"
>
<feather-icon icon="CheckIcon" />
</b-avatar>
</span>
<div class="d-flex justify-content-between">
<span class="font-weight-bolder">{{ item.wallet }}
<b-avatar
v-if="item.wallet===walletName"
variant="success"
size="sm"
>
<feather-icon icon="CheckIcon" />
</b-avatar>
</span>
<b-link :to="`/${selected_chain.chain_name}/account/${item.address.addr}`">
<feather-icon icon="ArrowRightIcon" />
</b-link>
</div>
<small>{{ item.address ? formatAddr(item.address.addr) : `Not available on ${selected_chain.chain_name}` }}</small>
</div>
</b-dropdown-item>

View File

@ -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) {