shop-web/src/layout/index.vue

33 lines
1.0 KiB
Vue
Raw Normal View History

2025-03-05 09:22:29 +08:00
<script setup lang="ts">
import { useKeepAliveStore } from "@/pinia/stores/keep-alive"
import Footer from "./components/Footer.vue"
import NavBar from "./components/NavBar.vue"
import Tabbar from "./components/Tabbar.vue"
const route = useRoute()
const keepAliveStore = useKeepAliveStore()
const showNavBar = computed(() => route.meta.layout?.navBar?.showNavBar)
const showTabbar = computed(() => route.meta.layout?.tabbar?.showTabbar)
const showFooter = computed(() => route.meta.layout?.footer)
</script>
<template>
<div un-h-full un-flex un-flex-col>
<NavBar v-if="showNavBar" />
<div un-flex-1 un-overflow-y-auto>
<!-- key 采用 route.path route.fullPath 有着不同的效果大多数时候 path 更通用 -->
<router-view v-slot="{ Component }">
<keep-alive :include="keepAliveStore.cachedRoutes">
<component :is="Component" :key="route.path" />
</keep-alive>
</router-view>
<Footer v-if="showFooter" />
</div>
<Tabbar v-if="showTabbar" />
</div>
</template>