forked from cerc-io/cosmos-explorer
fix: chain network switch
This commit is contained in:
parent
f693684222
commit
6a9823893c
@ -1,84 +1,89 @@
|
||||
<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">
|
||||
<div class="dropdown">
|
||||
<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="dropdown-content w-80 menu shadow bg-base-200 rounded-box max-h-[300px] overflow-auto"
|
||||
>
|
||||
<!-- rest -->
|
||||
<div class="flex-1 w-0">
|
||||
<div
|
||||
class="px-4 py-2 text-sm text-gray-400"
|
||||
v-if="chainStore.current?.endpoints?.rest"
|
||||
: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"
|
||||
>
|
||||
Rest Endpoint
|
||||
#{{
|
||||
baseStore.latest?.block?.header?.height ||
|
||||
chainStore.chainName ||
|
||||
''
|
||||
}}
|
||||
</div>
|
||||
<label
|
||||
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"
|
||||
:key="index"
|
||||
<div
|
||||
class="text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap hidden md:!block"
|
||||
>
|
||||
<div class="flex flex-col"
|
||||
@click="changeEndpoint(item)">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
<div class="text-gray-500 dark:text-gray-200 capitalize">
|
||||
{{ item.provider }}
|
||||
</div>
|
||||
<span
|
||||
v-if="item.address === chainStore.endpoint?.address"
|
||||
class="bg-yes inline-block h-2 w-2 rounded-full"
|
||||
/>
|
||||
</div>
|
||||
<div class="text-gray-400 text-xs whitespace-nowrap">
|
||||
{{ 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]">
|
||||
<div class="py-2 px-4">
|
||||
Chain Id: {{ baseStore.latest.block?.header.chain_id }}
|
||||
</div>
|
||||
<div class="py-2 px-4">
|
||||
Height: {{ baseStore.latest.block?.header.height }}
|
||||
</div>
|
||||
{{ chainStore.connErr || chainStore.endpoint.address }}
|
||||
</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"
|
||||
</label>
|
||||
<div
|
||||
tabindex="0"
|
||||
class="dropdown-content w-80 menu shadow bg-base-200 rounded-box max-h-[300px] overflow-auto"
|
||||
>
|
||||
<!-- rest -->
|
||||
<div
|
||||
class="px-4 py-2 text-sm text-gray-400"
|
||||
v-if="chainStore.current?.endpoints?.rest"
|
||||
>
|
||||
#{{
|
||||
baseStore.latest?.block?.header?.height || chainStore.chainName || ''
|
||||
}}
|
||||
Rest Endpoint
|
||||
</div>
|
||||
<div
|
||||
class="text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap hidden md:!block"
|
||||
v-for="(item, index) in chainStore.current?.endpoints?.rest"
|
||||
class="px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-[#384059] cursor-pointer"
|
||||
:key="index"
|
||||
@click="changeEndpoint(item)"
|
||||
>
|
||||
{{ chainStore.connErr || chainStore.endpoint.address }}
|
||||
<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 }}
|
||||
</div>
|
||||
<span
|
||||
v-if="item.address === chainStore.endpoint?.address"
|
||||
class="bg-yes inline-block h-2 w-2 rounded-full"
|
||||
/>
|
||||
</div>
|
||||
<div class="text-gray-400 text-xs whitespace-nowrap">
|
||||
{{ item.address }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 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>
|
||||
<div class="py-2 px-4">
|
||||
Height: {{ baseStore.latest.block?.header.height }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user