-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavBar.vue
44 lines (36 loc) · 925 Bytes
/
NavBar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script setup lang="ts">
import { routeWhiteList } from '@/config/routes'
const route = useRoute()
const router = useRouter()
const { t } = useI18n()
// 定义需要隐藏导航栏的路径
const hideNavBarPaths = ['/map']
function onBack() {
if (window.history.state.back)
history.back()
else
router.replace('/')
}
const title = computed(() => {
if (!route.meta)
return ''
return route.meta.i18n ? t(route.meta.i18n) : (route.meta.title || '')
})
// 添加显示控制计算属性
const show = computed(() => {
const currentPath = route.path
return !hideNavBarPaths.some(path => currentPath.startsWith(path))
})
const showLeftArrow = computed(() => route.name && routeWhiteList.includes(route.name))
</script>
<template>
<VanNavBar
v-if="show"
:title="title"
:fixed="true"
clickable
placeholder
:left-arrow="!showLeftArrow"
@click-left="onBack"
/>
</template>