TOPVERSE_Official/components/header/nav.vue

61 lines
2.1 KiB
Vue
Raw Normal View History

2023-04-27 13:58:47 +08:00
<script setup lang="ts">
import { useNav } from '~/config/use-nav'
2023-04-26 20:43:10 +08:00
2023-04-27 13:58:47 +08:00
const navs = useNav()
2023-05-07 16:38:23 +08:00
const { locale, locales, setLocale } = useI18n()
const switchLocalePath = useSwitchLocalePath()
const availableLocales = computed(() => {
// @ts-expect-error
return (locales.value).filter(i => i.code !== locale.value)
})
2023-05-07 16:42:52 +08:00
const flag: any = {
en: 'i-flag-gb-4x3',
zh: 'i-flag-cn-4x3',
}
2023-04-23 23:14:52 +08:00
</script>
<template>
2023-05-04 00:47:08 +08:00
<nav>
2023-05-07 16:38:23 +08:00
<LocaleNuxtLink v-for="(nav, i) in navs" :key="i" class="mx-2 border-primary p-1 pb-5 transition-all" :href="nav.href" active-class="border-b-3px">
2023-05-04 00:47:08 +08:00
<ABtn variant="text">
2023-05-07 16:38:23 +08:00
<AMenu v-if="nav.child" style="--un-bg-opacity:0.6;--a-spacing:2" class="" z-1000 mt-5 placement="bottom">
2023-04-23 23:14:52 +08:00
<AList
:items="nav.child"
avatar-append
2023-05-07 16:38:23 +08:00
class="[--a-list-item-gap:1rem] [--a-spacing:1] border-1px border-light-50/20 backdrop-blur-md !m-0 divide-y divide-dark-50/10 dark:(border-dark-50/20 divide-light-50/10)"
2023-04-23 23:14:52 +08:00
>
2023-05-07 16:38:23 +08:00
<LocaleNuxtLink v-for="(item, index) in nav.child" :key="index" :href="item.href" class="overflow-hidden py-1 hover:(bg-primary/20)" active-class="bg-primary/20">
2023-04-23 23:14:52 +08:00
<AListItem
2023-05-04 00:47:08 +08:00
class="[--a-spacing:1] max-w-300px"
2023-04-30 13:34:13 +08:00
:title="$t(item.title)"
2023-05-04 00:47:08 +08:00
:subtitle="item.subtitle && $t(item.subtitle)"
>
<template #prepend>
<AAvatar
2023-05-04 17:42:22 +08:00
class="shrink-0 rounded-lg"
2023-05-04 00:47:08 +08:00
:icon="item.icon"
/>
</template>
</AListItem>
2023-05-07 16:38:23 +08:00
</LocaleNuxtLink>
2023-04-23 23:14:52 +08:00
</AList>
</AMenu>
2023-05-04 00:47:08 +08:00
<span style="color: hsla(var(--a-base-c), 0.87); " class="font-bold">{{ $t(nav.title) }}</span>
2023-04-23 23:14:52 +08:00
</ABtn>
2023-05-07 16:38:23 +08:00
</LocaleNuxtLink>
<LocaleNuxtLink
v-for="locale in availableLocales" :key="locale.code" :to="switchLocalePath(locale.code)"
class="mx-2 border-primary p-1 pb-5 transition-all"
>
<ABtn
variant="text"
>
2023-05-07 16:46:31 +08:00
<span :class="flag[locale.code]" />
2023-05-07 16:38:23 +08:00
</ABtn>
</LocaleNuxtLink>
2023-04-23 23:14:52 +08:00
</nav>
</template>