forked from cerc-io/cosmos-explorer
fix: chain network switch
This commit is contained in:
parent
f693684222
commit
6a9823893c
@ -1,28 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import router from '@/router';
|
||||
import { useBlockchain, useBaseStore, type Endpoint } from '@/stores';
|
||||
import { useRouter } from 'vue-router';
|
||||
const chainStore = useBlockchain();
|
||||
const baseStore = useBaseStore();
|
||||
chainStore.initial();
|
||||
const router = useRouter();
|
||||
function changeEndpoint(item: Endpoint) {
|
||||
console.log('change')
|
||||
chainStore.setRestEndpoint(item)
|
||||
const router = useRouter()
|
||||
if(chainStore.current) router.push(`/${chainStore.current.chainName}`)
|
||||
chainStore.setRestEndpoint(item);
|
||||
if (chainStore.current) router.push(`/${chainStore.current.chainName}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center">
|
||||
<div class="dropdown">
|
||||
<div tabindex="0" class="p-1 relative mr-3 cursor-pointer">
|
||||
<label tabindex="0" class="flex items-center">
|
||||
<div class="p-1 relative mr-3 cursor-pointer">
|
||||
<img v-lazy="chainStore.logo" class="w-9 h-9 rounded-full" />
|
||||
<div
|
||||
class="w-2 h-2 rounded-full bg-yes absolute right-0 bottom-0 shadow"
|
||||
></div>
|
||||
</div>
|
||||
<div class="flex-1 w-0">
|
||||
<div
|
||||
:key="
|
||||
baseStore.latest?.block?.header?.height ||
|
||||
chainStore.chainName ||
|
||||
''
|
||||
"
|
||||
class="capitalize whitespace-nowrap text-base font-semibold text-gray-600 dark:text-gray-200 hidden md:!block"
|
||||
>
|
||||
#{{
|
||||
baseStore.latest?.block?.header?.height ||
|
||||
chainStore.chainName ||
|
||||
''
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
class="text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap hidden md:!block"
|
||||
>
|
||||
{{ chainStore.connErr || chainStore.endpoint.address }}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<div
|
||||
tabindex="0"
|
||||
class="dropdown-content w-80 menu shadow bg-base-200 rounded-box max-h-[300px] overflow-auto"
|
||||
>
|
||||
<!-- rest -->
|
||||
@ -32,13 +53,13 @@ function changeEndpoint(item: Endpoint) {
|
||||
>
|
||||
Rest Endpoint
|
||||
</div>
|
||||
<label
|
||||
<div
|
||||
v-for="(item, index) in chainStore.current?.endpoints?.rest"
|
||||
class="px-4 py-2 w-full hover:bg-gray-100 dark:bg-[#384059] cursor-pointer"
|
||||
class="px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-[#384059] cursor-pointer"
|
||||
:key="index"
|
||||
@click="changeEndpoint(item)"
|
||||
>
|
||||
<div class="flex flex-col"
|
||||
@click="changeEndpoint(item)">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div class="text-gray-500 dark:text-gray-200 capitalize">
|
||||
{{ item.provider }}
|
||||
@ -52,12 +73,11 @@ function changeEndpoint(item: Endpoint) {
|
||||
{{ item.address }}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<!-- rest -->
|
||||
<div class="px-4 py-2 text-sm text-gray-400">
|
||||
Information
|
||||
</div>
|
||||
<div class="w-full hover:bg-gray-100 dark:bg-[#384059]">
|
||||
|
||||
<!-- rest -->
|
||||
<div class="px-4 py-2 text-sm text-gray-400">Information</div>
|
||||
<div class="w-full">
|
||||
<div class="py-2 px-4">
|
||||
Chain Id: {{ baseStore.latest.block?.header.chain_id }}
|
||||
</div>
|
||||
@ -67,19 +87,4 @@ function changeEndpoint(item: Endpoint) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1 w-0">
|
||||
<div :key="baseStore.latest?.block?.header?.height || chainStore.chainName || ''"
|
||||
class="capitalize whitespace-nowrap text-base font-semibold text-gray-600 dark:text-gray-200 hidden md:!block"
|
||||
>
|
||||
#{{
|
||||
baseStore.latest?.block?.header?.height || chainStore.chainName || ''
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
class="text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap hidden md:!block"
|
||||
>
|
||||
{{ chainStore.connErr || chainStore.endpoint.address }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user