forked from cerc-io/cosmos-explorer
add wallet swith on menu
This commit is contained in:
parent
5217cb658d
commit
27d46e0b13
@ -106,16 +106,26 @@
|
|||||||
</b-button>
|
</b-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- <b-dropdown-item
|
<b-dropdown-item
|
||||||
:to="{ name: 'portfolio' }"
|
v-for="(item,k) in accounts"
|
||||||
class="d-none"
|
:key="k"
|
||||||
|
:disabled="!item.address"
|
||||||
|
@click="updateDefaultWallet(item.wallet)"
|
||||||
>
|
>
|
||||||
<feather-icon
|
<div class="d-flex flex-column">
|
||||||
icon="PieChartIcon"
|
<span class="font-weight-bolder">{{ item.wallet }}
|
||||||
size="16"
|
<b-avatar
|
||||||
/>
|
v-if="item.wallet===walletName"
|
||||||
<span class="align-middle ml-50">Portofolio</span>
|
variant="success"
|
||||||
</b-dropdown-item> -->
|
size="sm"
|
||||||
|
>
|
||||||
|
<feather-icon icon="CheckIcon" />
|
||||||
|
</b-avatar>
|
||||||
|
</span>
|
||||||
|
<small>{{ item.address ? formatAddr(item.address.addr) : `Not available for ${selected_chain.chain_name}` }}</small>
|
||||||
|
</div>
|
||||||
|
</b-dropdown-item>
|
||||||
|
<b-dropdown-divider />
|
||||||
|
|
||||||
<b-dropdown-item :to="{ name: 'accounts' }">
|
<b-dropdown-item :to="{ name: 'accounts' }">
|
||||||
<feather-icon
|
<feather-icon
|
||||||
@ -155,7 +165,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
BLink, BNavbarNav, BMedia, BMediaAside, BAvatar, BMediaBody, VBTooltip, BButton,
|
BLink, BNavbarNav, BMedia, BMediaAside, BAvatar, BMediaBody, VBTooltip, BButton,
|
||||||
BDropdown, BDropdownItem,
|
BDropdown, BDropdownItem, BDropdownDivider,
|
||||||
} from 'bootstrap-vue'
|
} from 'bootstrap-vue'
|
||||||
import Ripple from 'vue-ripple-directive'
|
import Ripple from 'vue-ripple-directive'
|
||||||
import DarkToggler from '@core/layouts/components/app-navbar/components/DarkToggler.vue'
|
import DarkToggler from '@core/layouts/components/app-navbar/components/DarkToggler.vue'
|
||||||
@ -176,6 +186,7 @@ export default {
|
|||||||
BButton,
|
BButton,
|
||||||
BDropdown,
|
BDropdown,
|
||||||
BDropdownItem,
|
BDropdownItem,
|
||||||
|
BDropdownDivider,
|
||||||
|
|
||||||
// Navbar Components
|
// Navbar Components
|
||||||
DarkToggler,
|
DarkToggler,
|
||||||
@ -224,14 +235,26 @@ export default {
|
|||||||
}
|
}
|
||||||
return [conf.api]
|
return [conf.api]
|
||||||
},
|
},
|
||||||
|
accounts() {
|
||||||
|
let accounts = getLocalAccounts() || {}
|
||||||
|
accounts = Object.entries(accounts).map(v => ({ wallet: v[0], address: v[1].address.find(x => x.chain === this.selected_chain.chain_name) }))
|
||||||
|
|
||||||
|
if (!this.$store.state.chains.defaultWallet && this.accounts.length > 0) {
|
||||||
|
this.updateDefaultWallet(this.accounts[0].wallet)
|
||||||
|
}
|
||||||
|
return accounts
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const accounts = Object.keys(getLocalAccounts() || {})
|
|
||||||
if (!this.$store.state.chains.defaultWallet && accounts.length > 0) {
|
|
||||||
this.$store.commit('setDefaultWallet', accounts[0])
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
formatAddr(v) {
|
||||||
|
return v.substring(0, 10).concat('...', v.substring(v.length - 10))
|
||||||
|
},
|
||||||
|
updateDefaultWallet(v) {
|
||||||
|
this.$store.commit('setDefaultWallet', v)
|
||||||
|
},
|
||||||
change(v) {
|
change(v) {
|
||||||
this.index = v
|
this.index = v
|
||||||
const conf = this.$store.state.chains.selected
|
const conf = this.$store.state.chains.selected
|
||||||
|
Loading…
Reference in New Issue
Block a user