Merge pull request #398 from alisaweb3/v3-single

Fix: switch chain network, NavBarWallet Warning
This commit is contained in:
ping 2023-05-26 15:19:06 +08:00 committed by GitHub
commit 4d05e8ebf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 158 additions and 110 deletions

View File

@ -1,28 +1,49 @@
<script setup lang="ts"> <script setup lang="ts">
import router from '@/router';
import { useBlockchain, useBaseStore, type Endpoint } from '@/stores'; import { useBlockchain, useBaseStore, type Endpoint } from '@/stores';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const chainStore = useBlockchain(); const chainStore = useBlockchain();
const baseStore = useBaseStore(); const baseStore = useBaseStore();
chainStore.initial(); chainStore.initial();
const router = useRouter();
function changeEndpoint(item: Endpoint) { function changeEndpoint(item: Endpoint) {
console.log('change') chainStore.setRestEndpoint(item);
chainStore.setRestEndpoint(item) if (chainStore.current) router.push(`/${chainStore.current.chainName}`);
const router = useRouter()
if(chainStore.current) router.push(`/${chainStore.current.chainName}`)
} }
</script> </script>
<template> <template>
<div class="flex items-center">
<div class="dropdown"> <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" /> <img v-lazy="chainStore.logo" class="w-9 h-9 rounded-full" />
<div <div
class="w-2 h-2 rounded-full bg-yes absolute right-0 bottom-0 shadow" class="w-2 h-2 rounded-full bg-yes absolute right-0 bottom-0 shadow"
></div> ></div>
</div> </div>
<div class="flex-1 w-0">
<div <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" class="dropdown-content w-80 menu shadow bg-base-200 rounded-box max-h-[300px] overflow-auto"
> >
<!-- rest --> <!-- rest -->
@ -32,13 +53,13 @@ function changeEndpoint(item: Endpoint) {
> >
Rest Endpoint Rest Endpoint
</div> </div>
<label <div
v-for="(item, index) in chainStore.current?.endpoints?.rest" 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" :key="index"
@click="changeEndpoint(item)"
> >
<div class="flex flex-col" <div class="flex flex-col">
@click="changeEndpoint(item)">
<div class="flex items-center justify-between w-full"> <div class="flex items-center justify-between w-full">
<div class="text-gray-500 dark:text-gray-200 capitalize"> <div class="text-gray-500 dark:text-gray-200 capitalize">
{{ item.provider }} {{ item.provider }}
@ -52,12 +73,11 @@ function changeEndpoint(item: Endpoint) {
{{ item.address }} {{ item.address }}
</div> </div>
</div> </div>
</label>
<!-- rest -->
<div class="px-4 py-2 text-sm text-gray-400">
Information
</div> </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"> <div class="py-2 px-4">
Chain Id: {{ baseStore.latest.block?.header.chain_id }} Chain Id: {{ baseStore.latest.block?.header.chain_id }}
</div> </div>
@ -67,19 +87,4 @@ function changeEndpoint(item: Endpoint) {
</div> </div>
</div> </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> </template>

View File

@ -20,10 +20,10 @@ const dashboard = useDashboard();
dashboard.initial(); dashboard.initial();
const blockchain = useBlockchain(); const blockchain = useBlockchain();
const current = ref("") const current = ref('');
blockchain.$subscribe((m, s) => { blockchain.$subscribe((m, s) => {
if (current.value != s.chainName) { if (current.value != s.chainName) {
current.value = s.chainName current.value = s.chainName;
blockchain.initial(); blockchain.initial();
} }
}); });
@ -36,7 +36,7 @@ const changeOpen = (index: Number) => {
sidebarOpen.value = !sidebarOpen.value; sidebarOpen.value = !sidebarOpen.value;
} }
}; };
const showDiscord = window.location.host.search("ping.pub") > -1 const showDiscord = window.location.host.search('ping.pub') > -1;
</script> </script>
<template> <template>
@ -51,7 +51,10 @@ const showDiscord = window.location.host.search("ping.pub") > -1
<h1 class="flex-1 ml-3 text-2xl font-semibold dark:text-white"> <h1 class="flex-1 ml-3 text-2xl font-semibold dark:text-white">
Ping.pub Ping.pub
</h1> </h1>
<div class="pr-4 cursor-pointer xl:!hidden" @click="sidebarShow = false"> <div
class="pr-4 cursor-pointer xl:!hidden"
@click="sidebarShow = false"
>
<Icon icon="mdi-close" class="text-3xl" /> <Icon icon="mdi-close" class="text-3xl" />
</div> </div>
</div> </div>
@ -95,7 +98,8 @@ const showDiscord = window.location.host.search("ping.pub") > -1
</div> </div>
<div <div
v-if="item?.badgeContent" v-if="item?.badgeContent"
class="mr-6 badge badge-sm" :class="item?.badgeClass" class="mr-6 badge badge-sm"
:class="item?.badgeClass"
> >
{{ item?.badgeContent }} {{ item?.badgeContent }}
</div> </div>
@ -165,7 +169,8 @@ const showDiscord = window.location.host.search("ping.pub") > -1
</div> </div>
<div <div
v-if="item?.badgeContent" v-if="item?.badgeContent"
class="mr-6 badge badge-sm" :class="item?.badgeClass" class="mr-6 badge badge-sm"
:class="item?.badgeClass"
> >
{{ item?.badgeContent }} {{ item?.badgeContent }}
</div> </div>
@ -181,37 +186,67 @@ const showDiscord = window.location.host.search("ping.pub") > -1
<div class="px-4 text-sm pt-4 text-gray-400 pb-2 uppercase"> <div class="px-4 text-sm pt-4 text-gray-400 pb-2 uppercase">
Sponsors Sponsors
</div> </div>
<a href="https://osmosis.zone" class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"> <a
<img src="https://ping.pub/logos/osmosis.jpg" class="w-6 h-6 rounded-full mr-3"/> href="https://osmosis.zone"
<div class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"> class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
>
<img
src="https://ping.pub/logos/osmosis.jpg"
class="w-6 h-6 rounded-full mr-3"
/>
<div
class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"
>
Osmosis Osmosis
</div> </div>
</a> </a>
<a href="https://becole.com" class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"> <a
<img src="https://becole.com/static/logo/logo_becole.png" class="w-6 h-6 rounded-full mr-3"/> href="https://becole.com"
<div class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"> class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
>
<img
src="https://becole.com/static/logo/logo_becole.png"
class="w-6 h-6 rounded-full mr-3"
/>
<div
class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"
>
Becole Becole
</div> </div>
</a> </a>
<div class="px-4 text-sm pt-4 text-gray-400 pb-2 uppercase"> <div class="px-4 text-sm pt-4 text-gray-400 pb-2 uppercase">Links</div>
Links <a
</div> href="https://twitter.com/ping_pub"
<a href="https://twitter.com/ping_pub" class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"> class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
>
<Icon icon="mdi:twitter" class="text-xl mr-2" /> <Icon icon="mdi:twitter" class="text-xl mr-2" />
<div class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"> <div
class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"
>
Twitter Twitter
</div> </div>
</a> </a>
<a v-if="showDiscord" href="https://discord.com/invite/CmjYVSr6GW" class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"> <a
v-if="showDiscord"
href="https://discord.com/invite/CmjYVSr6GW"
class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
>
<Icon icon="mdi:discord" class="text-xl mr-2" /> <Icon icon="mdi:discord" class="text-xl mr-2" />
<div class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"> <div
class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"
>
Discord Discord
</div> </div>
</a> </a>
<a href="https://github.com/ping-pub/explorer/discussions" class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"> <a
href="https://github.com/ping-pub/explorer/discussions"
class="collapse-title px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
>
<Icon icon="mdi:frequently-asked-questions" class="text-xl mr-2" /> <Icon icon="mdi:frequently-asked-questions" class="text-xl mr-2" />
<div class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"> <div
class="text-base capitalize flex-1 text-gray-700 dark:text-gray-200"
>
FAQ FAQ
</div> </div>
</a> </a>
@ -237,9 +272,7 @@ const showDiscord = window.location.host.search("ping.pub") > -1
<NavBarI18n class="hidden md:!inline-block" /> <NavBarI18n class="hidden md:!inline-block" />
<NavbarThemeSwitcher class="!inline-block" /> <NavbarThemeSwitcher class="!inline-block" />
<NavBarWallet <NavBarWallet />
class="hidden truncate md:!inline-block text-xs md:!text-sm"
/>
</div> </div>
<!-- 👉 Pages --> <!-- 👉 Pages -->

View File

@ -4,7 +4,7 @@ import { Icon } from '@iconify/vue';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
const walletStore = useWalletStore(); const walletStore = useWalletStore();
const chainStore = useBlockchain(); const chainStore = useBlockchain();
const baseStore = useBaseStore() const baseStore = useBaseStore();
// walletStore.$subscribe((m, s) => { // walletStore.$subscribe((m, s) => {
// console.log(m, s); // console.log(m, s);
// }); // });
@ -31,18 +31,18 @@ const tipMsg = computed(() => {
? { class: 'error', msg: 'Copy Error!' } ? { class: 'error', msg: 'Copy Error!' }
: { class: 'success', msg: 'Copy Success!' }; : { class: 'success', msg: 'Copy Success!' };
}); });
</script> </script>
<template> <template>
<div <div class="dropdown dropdown-hover dropdown-end">
class="dropdown dropdown-hover dropdown-end" <label
tabindex="0"
class="btn btn-sm m-1 lowercase hidden truncate md:!inline-flex text-xs md:!text-sm"
> >
<label tabindex="0" class="btn btn-sm m-1 lowercase">
<Icon icon="mdi:wallet" /> <Icon icon="mdi:wallet" />
<span class="ml-1 hidden md:block"> <span class="ml-1 hidden md:block">
{{ walletStore.shortAddress || "Wallet" }}</span> {{ walletStore.shortAddress || 'Wallet' }}</span
>
</label> </label>
<div <div
tabindex="0" tabindex="0"
@ -52,7 +52,9 @@ const tipMsg = computed(() => {
v-if="!walletStore?.currentAddress" v-if="!walletStore?.currentAddress"
for="PingConnectWallet" for="PingConnectWallet"
class="btn btn-sm" class="btn btn-sm"
><Icon icon="mdi:wallet"/><span class="ml-1 hidden md:block">Connect Wallet</span></label ><Icon icon="mdi:wallet" /><span class="ml-1 hidden md:block"
>Connect Wallet</span
></label
> >
<div class="px-2 mb-1 text-gray-500 dark:text-gray-400 font-semibold"> <div class="px-2 mb-1 text-gray-500 dark:text-gray-400 font-semibold">
{{ walletStore.connectedWallet?.wallet }} {{ walletStore.connectedWallet?.wallet }}
@ -100,9 +102,7 @@ const tipMsg = computed(() => {
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="footer-modal">
<Teleport to="body"> <Teleport to="body">
<ping-connect-wallet <ping-connect-wallet
:chain-id="baseStore.currentChainId" :chain-id="baseStore.currentChainId"
@ -110,7 +110,6 @@ const tipMsg = computed(() => {
@connect="walletStateChange" @connect="walletStateChange"
/> />
</Teleport> </Teleport>
</div>
</template> </template>
<style> <style>

View File

@ -15,7 +15,18 @@ import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
vue(), vue({
template: {
compilerOptions: {
isCustomElement: (tag) =>
[
'ping-connect-wallet',
'ping-token-convert',
'ping-tx-dialog',
].includes(tag),
},
},
}),
vueJsx(), vueJsx(),
vuetify({ vuetify({
styles: { styles: {