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

View File

@ -248,6 +248,16 @@ export default {
computed: { computed: {
walletName() { walletName() {
const key = this.$store?.state?.chains?.defaultWallet 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' return key || 'Wallet'
}, },
}, },
@ -290,15 +300,6 @@ export default {
this.$http.getGovernanceListByStatus(2).then(res => { this.$http.getGovernanceListByStatus(2).then(res => {
this.proposals = res.proposals 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: { methods: {
formatToken(tokens) { formatToken(tokens) {