fix nav issue
This commit is contained in:
parent
a336be1833
commit
b8d10fa373
@ -13,7 +13,7 @@ import { useBlockchain } from '@/stores';
|
|||||||
|
|
||||||
import NavBarI18n from './NavBarI18n.vue';
|
import NavBarI18n from './NavBarI18n.vue';
|
||||||
import NavBarWallet from './NavBarWallet.vue';
|
import NavBarWallet from './NavBarWallet.vue';
|
||||||
import type { NavGroup, NavLink, NavSectionTitle } from '../types';
|
import type { NavGroup, NavLink, NavSectionTitle, VerticalNavItems } from '../types';
|
||||||
|
|
||||||
const dashboard = useDashboard();
|
const dashboard = useDashboard();
|
||||||
dashboard.initial();
|
dashboard.initial();
|
||||||
@ -37,15 +37,19 @@ const changeOpen = (index: Number) => {
|
|||||||
};
|
};
|
||||||
const showDiscord = window.location.host.search('ping.pub') > -1;
|
const showDiscord = window.location.host.search('ping.pub') > -1;
|
||||||
|
|
||||||
function isNavGroup(nav: NavGroup | NavLink | NavSectionTitle | any): nav is NavGroup {
|
function isNavGroup(nav: VerticalNavItems | any): nav is NavGroup {
|
||||||
return (<NavGroup>nav).children !== undefined;
|
return (<NavGroup>nav).children !== undefined;
|
||||||
}
|
}
|
||||||
function isNavLink(nav: NavGroup | NavLink | NavSectionTitle | any): nav is NavLink {
|
function isNavLink(nav: VerticalNavItems | any): nav is NavLink {
|
||||||
return (<NavLink>nav).to !== undefined;
|
return (<NavLink>nav).to !== undefined;
|
||||||
}
|
}
|
||||||
function isNavTitle(nav: NavGroup | NavLink | NavSectionTitle | any): nav is NavSectionTitle {
|
function isNavTitle(nav: VerticalNavItems | any): nav is NavSectionTitle {
|
||||||
return (<NavSectionTitle>nav).heading !== undefined;
|
return (<NavSectionTitle>nav).heading !== undefined;
|
||||||
}
|
}
|
||||||
|
function selected(route: any, nav: NavLink) {
|
||||||
|
const b = route.path === nav.to?.path || route.path.startsWith(nav.to?.path) && nav.title.indexOf('dashboard') === -1
|
||||||
|
return b
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -118,17 +122,15 @@ function isNavTitle(nav: NavGroup | NavLink | NavSectionTitle | any): nav is Nav
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse-content">
|
<div class="collapse-content">
|
||||||
<div class="menu bg-base-100 w-full">
|
<div v-for="(el, key) of item?.children" class="menu bg-base-100 w-full">
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-for="(el, key) of item?.children"
|
v-if="isNavLink(el)"
|
||||||
@click="sidebarShow = false"
|
@click="sidebarShow = false"
|
||||||
:key="key"
|
|
||||||
class="hover:bg-gray-100 dark:hover:bg-[#373f59] rounded cursor-pointer px-3 py-2 flex items-center"
|
class="hover:bg-gray-100 dark:hover:bg-[#373f59] rounded cursor-pointer px-3 py-2 flex items-center"
|
||||||
:to="el?.to"
|
|
||||||
:class="{
|
:class="{
|
||||||
'!bg-primary':
|
'!bg-primary': selected($route, el),
|
||||||
$route.path === el?.to?.path && item?.title !== 'Favorite',
|
|
||||||
}"
|
}"
|
||||||
|
:to="el.to"
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
v-if="!el?.icon?.image"
|
v-if="!el?.icon?.image"
|
||||||
@ -148,9 +150,7 @@ function isNavTitle(nav: NavGroup | NavLink | NavSectionTitle | any): nav is Nav
|
|||||||
<div
|
<div
|
||||||
class="text-base capitalize text-gray-500 dark:text-gray-300"
|
class="text-base capitalize text-gray-500 dark:text-gray-300"
|
||||||
:class="{
|
:class="{
|
||||||
'text-white':
|
'text-white': item?.title !== 'Favorite',
|
||||||
$route.path === el?.to?.path &&
|
|
||||||
item?.title !== 'Favorite',
|
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{ item?.title === 'Favorite' ? el?.title : $t(el?.title) }}
|
{{ item?.title === 'Favorite' ? el?.title : $t(el?.title) }}
|
||||||
@ -161,8 +161,8 @@ function isNavTitle(nav: NavGroup | NavLink | NavSectionTitle | any): nav is Nav
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<RouterLink
|
<RouterLink
|
||||||
|
v-if="isNavLink(item)"
|
||||||
:to="item?.to"
|
:to="item?.to"
|
||||||
v-if="isNavGroup(item)"
|
|
||||||
@click="sidebarShow = false"
|
@click="sidebarShow = false"
|
||||||
class="cursor-pointer rounded-lg px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
|
class="cursor-pointer rounded-lg px-4 flex items-center py-2 hover:bg-gray-100 dark:hover:bg-[#373f59]"
|
||||||
>
|
>
|
||||||
|
7
src/layouts/types.d.ts
vendored
7
src/layouts/types.d.ts
vendored
@ -37,21 +37,22 @@ export interface Icon {
|
|||||||
export interface NavLink extends NavLinkProps {
|
export interface NavLink extends NavLinkProps {
|
||||||
title: string
|
title: string
|
||||||
icon?: Icon
|
icon?: Icon
|
||||||
badgeContent?: string
|
badgeContent?: string | number
|
||||||
badgeClass?: string
|
badgeClass?: string
|
||||||
disable?: boolean
|
disable?: boolean
|
||||||
order?: number
|
order?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 👉 Vertical nav group
|
// 👉 Vertical nav group
|
||||||
export interface NavGroup extends NavLinkProps {
|
export interface NavGroup {
|
||||||
title: string
|
title: string
|
||||||
icon?: Icon
|
icon?: Icon
|
||||||
badgeContent?: string
|
badgeContent?: string | number
|
||||||
badgeClass?: string
|
badgeClass?: string
|
||||||
children: (NavLink | NavGroup)[]
|
children: (NavLink | NavGroup)[]
|
||||||
disable?: boolean
|
disable?: boolean
|
||||||
order?: number
|
order?: number
|
||||||
|
i18n?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare type VerticalNavItems = (NavLink | NavGroup | NavSectionTitle)[]
|
export declare type VerticalNavItems = (NavLink | NavGroup | NavSectionTitle)[]
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
type Endpoint,
|
type Endpoint,
|
||||||
EndpointType,
|
EndpointType,
|
||||||
} from './useDashboard';
|
} from './useDashboard';
|
||||||
import type { VerticalNavItems } from '@/layouts/types';
|
import type { NavGroup, NavLink, NavSectionTitle, VerticalNavItems } from '@/layouts/types';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { CosmosRestClient } from '@/libs/client';
|
import { CosmosRestClient } from '@/libs/client';
|
||||||
import {
|
import {
|
||||||
@ -103,7 +103,7 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
// combine all together
|
// combine all together
|
||||||
return [
|
return [
|
||||||
...currNavItem,
|
...currNavItem,
|
||||||
{ heading: 'Ecosystem' },
|
{ heading: 'Ecosystem' } as NavSectionTitle,
|
||||||
{
|
{
|
||||||
title: 'Favorite',
|
title: 'Favorite',
|
||||||
children: favNavItems,
|
children: favNavItems,
|
||||||
@ -111,7 +111,7 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
badgeClass: 'bg-primary',
|
badgeClass: 'bg-primary',
|
||||||
i18n: true,
|
i18n: true,
|
||||||
icon: { icon: 'mdi-star', size: '22' },
|
icon: { icon: 'mdi-star', size: '22' },
|
||||||
},
|
} as NavGroup,
|
||||||
{
|
{
|
||||||
title: 'All Blockchains',
|
title: 'All Blockchains',
|
||||||
to: { path: '/' },
|
to: { path: '/' },
|
||||||
@ -119,7 +119,7 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
badgeClass: 'bg-primary',
|
badgeClass: 'bg-primary',
|
||||||
i18n: true,
|
i18n: true,
|
||||||
icon: { icon: 'mdi-grid', size: '22' },
|
icon: { icon: 'mdi-grid', size: '22' },
|
||||||
},
|
} as NavLink,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user