refactor: always display the navbar on the page

This commit is contained in:
CharleeWa 2024-08-18 22:07:32 +08:00
parent 90bec318c2
commit 085ff2fbf8
12 changed files with 38 additions and 20 deletions

View File

@ -17,14 +17,22 @@ const title = computed(() => {
return route.meta.i18n ? t(route.meta.i18n) : (route.meta.title || '')
})
const showLeftArrow = computed(() => {
if (!route.meta)
return false
return route.meta.level === 2
})
</script>
<template>
<VanNavBar
v-if="title"
:title="title"
:fixed="true"
clickable left-arrow placeholder
clickable
placeholder
:left-arrow="showLeftArrow"
@click-left="onBack"
/>
</template>

View File

@ -3,7 +3,7 @@ const { t } = useI18n()
const active = ref(0)
const route = useRoute()
const display = computed(() => {
const show = computed(() => {
if (route.meta.level && route.meta.level !== 2)
return true
return false
@ -11,7 +11,7 @@ const display = computed(() => {
</script>
<template>
<van-tabbar v-if="display" v-model="active" route placeholder>
<van-tabbar v-if="show" v-model="active" placeholder route>
<van-tabbar-item replace to="/">
{{ t('layouts.home') }}
<template #icon>

View File

@ -1,5 +1,7 @@
{
"home": {
"menus": {
"home": "Home",
"profile": "My Center",
"darkMode": "🌗 Dark Mode",
"mockGuide": "💿 Mock Guide",
"language": "📚 Language",

View File

@ -1,5 +1,7 @@
{
"home": {
"menus": {
"home": "主页",
"profile": "个人中心",
"darkMode": "🌗 暗黑模式",
"mockGuide": "💿 Mock 指南",
"language": "📚 语言",

View File

@ -2,6 +2,8 @@
definePage({
name: '404',
meta: {
title: '404',
i18n: 'menus.404Demo',
level: 2,
},
})

View File

@ -4,7 +4,7 @@ definePage({
meta: {
level: 2,
title: '📊 Echarts 演示',
i18n: 'home.echartsDemo',
i18n: 'menus.echartsDemo',
},
})

View File

@ -7,7 +7,7 @@ definePage({
meta: {
level: 2,
title: '🍍 持久化 Pinia 状态',
i18n: 'home.persistPiniaState',
i18n: 'menus.persistPiniaState',
},
})

View File

@ -6,6 +6,8 @@ import { languageColumns, locale } from '@/utils/i18n'
definePage({
name: 'home',
meta: {
title: '主页',
i18n: 'menus.home',
level: 1,
},
})
@ -38,19 +40,19 @@ function onLanguageConfirm(event: { selectedOptions: PickerColumn }) {
}
const menuItems = computed(() => ([
{ title: t('home.mockGuide'), route: 'mock' },
{ title: t('home.echartsDemo'), route: 'charts' },
{ title: t('home.unocssExample'), route: 'unocss' },
{ title: t('home.persistPiniaState'), route: 'counter' },
{ title: t('home.404Demo'), route: 'unknown' },
{ title: t('home.keepAlive'), route: 'keepalive' },
{ title: t('menus.mockGuide'), route: 'mock' },
{ title: t('menus.echartsDemo'), route: 'charts' },
{ title: t('menus.unocssExample'), route: 'unocss' },
{ title: t('menus.persistPiniaState'), route: 'counter' },
{ title: t('menus.404Demo'), route: 'unknown' },
{ title: t('menus.keepAlive'), route: 'keepalive' },
]))
</script>
<template>
<div class="pt-46">
<div class="pt-16">
<VanCellGroup inset>
<VanCell center :title="t('home.darkMode')">
<VanCell center :title="t('menus.darkMode')">
<template #right-icon>
<VanSwitch v-model="checked" size="20px" aria-label="on/off Dark Mode" @click="toggle()" />
</template>
@ -58,7 +60,7 @@ const menuItems = computed(() => ([
<VanCell
is-link
:title="t('home.language')"
:title="t('menus.language')"
:value="language"
@click="showLanguagePicker = true"
/>

View File

@ -8,7 +8,7 @@ definePage({
meta: {
level: 2,
title: '🧡 KeepAlive',
i18n: 'home.keepAlive',
i18n: 'menus.keepAlive',
keepAlive: true,
},
})

View File

@ -6,7 +6,7 @@ definePage({
meta: {
level: 2,
title: '💿 Mock 指南',
i18n: 'home.mockGuide',
i18n: 'menus.mockGuide',
},
})

View File

@ -2,6 +2,8 @@
definePage({
name: 'profile',
meta: {
title: '个人中心',
i18n: 'menus.profile',
level: 1,
},
})

View File

@ -4,7 +4,7 @@ definePage({
meta: {
level: 2,
title: '🎨 Unocss 示例',
i18n: 'home.unocssExample',
i18n: 'menus.unocssExample',
},
})
</script>