forked from cerc-io/cosmos-explorer
feat: wallet dropdown
This commit is contained in:
parent
f50e1c12bf
commit
f5ac321b8b
@ -1,10 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useWalletStore } from '@/stores';
|
import { useWalletStore } from '@/stores';
|
||||||
|
import {ref, computed} from 'vue'
|
||||||
const walletStore = useWalletStore();
|
const walletStore = useWalletStore();
|
||||||
walletStore.$subscribe((m, s) => {
|
walletStore.$subscribe((m, s) => {
|
||||||
console.log(m, s);
|
console.log(m, s);
|
||||||
});
|
});
|
||||||
|
let showCopyToast = ref(0)
|
||||||
|
async function copyAdress(address: string){
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(address);
|
||||||
|
showCopyToast.value = 1
|
||||||
|
setTimeout(()=>{
|
||||||
|
showCopyToast.value = 0
|
||||||
|
},1000)
|
||||||
|
/* Resolved - 文本被成功复制到剪贴板 */
|
||||||
|
} catch (err) {
|
||||||
|
showCopyToast.value = 2
|
||||||
|
setTimeout(()=>{
|
||||||
|
showCopyToast.value = 0
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const tipMsg = computed(()=> {
|
||||||
|
return showCopyToast.value === 2 ? {class: 'error', msg: 'Copy Error!'}: {class: 'success', msg: 'Copy Success!'}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -12,7 +31,9 @@ walletStore.$subscribe((m, s) => {
|
|||||||
v-show="walletStore.currentAddress"
|
v-show="walletStore.currentAddress"
|
||||||
class="dropdown dropdown-hover dropdown-end"
|
class="dropdown dropdown-hover dropdown-end"
|
||||||
>
|
>
|
||||||
<label tabindex="0" class="btn btn-sm m-1 lowercase">{{ walletStore.shortAddress }}</label>
|
<label tabindex="0" class="btn btn-sm m-1 lowercase">{{
|
||||||
|
walletStore.shortAddress
|
||||||
|
}}</label>
|
||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="dropdown-content menu shadow p-2 bg-base-100 rounded w-64 overflow-auto"
|
class="dropdown-content menu shadow p-2 bg-base-100 rounded w-64 overflow-auto"
|
||||||
@ -24,9 +45,22 @@ walletStore.$subscribe((m, s) => {
|
|||||||
<a
|
<a
|
||||||
class="block py-2 px-2 hover:bg-gray-100 dark:hover:bg-[#353f5a] rounded cursor-pointer"
|
class="block py-2 px-2 hover:bg-gray-100 dark:hover:bg-[#353f5a] rounded cursor-pointer"
|
||||||
style="overflow-wrap: anywhere"
|
style="overflow-wrap: anywhere"
|
||||||
|
@click="copyAdress(walletStore.currentAddress)"
|
||||||
>
|
>
|
||||||
{{ walletStore.currentAddress }}
|
{{ walletStore.currentAddress }}
|
||||||
</a>
|
</a>
|
||||||
|
<div class="divider mt-1 mb-1"></div>
|
||||||
|
<RouterLink
|
||||||
|
class="block py-2 px-2 hover:bg-gray-100 dark:hover:bg-[#353f5a] rounded cursor-pointer"
|
||||||
|
to="/wallet/accounts"
|
||||||
|
>Accounts</RouterLink
|
||||||
|
>
|
||||||
|
<RouterLink
|
||||||
|
class="block py-2 px-2 hover:bg-gray-100 dark:hover:bg-[#353f5a] rounded cursor-pointer"
|
||||||
|
to="/wallet/portfolio"
|
||||||
|
>Portfolio</RouterLink
|
||||||
|
>
|
||||||
|
<div class="divider mt-1 mb-1"></div>
|
||||||
<a
|
<a
|
||||||
class="block py-2 px-2 hover:bg-gray-100 dark:hover:bg-[#353f5a] rounded cursor-pointer"
|
class="block py-2 px-2 hover:bg-gray-100 dark:hover:bg-[#353f5a] rounded cursor-pointer"
|
||||||
@click="walletStore.disconnect()"
|
@click="walletStore.disconnect()"
|
||||||
@ -34,6 +68,20 @@ walletStore.$subscribe((m, s) => {
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="toast" v-show="showCopyToast===1">
|
||||||
|
<div class="alert alert-success">
|
||||||
|
<div class="text-sm">
|
||||||
|
<span>{{ tipMsg.msg }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="toast" v-show="showCopyToast===2">
|
||||||
|
<div class="alert alert-error">
|
||||||
|
<div class="text-sm">
|
||||||
|
<span>{{ tipMsg.msg }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<label
|
<label
|
||||||
v-if="!walletStore?.currentAddress"
|
v-if="!walletStore?.currentAddress"
|
||||||
|
Loading…
Reference in New Issue
Block a user