修复:修复前后台切换底部导航闪现
This commit is contained in:
+18
-6
@@ -16,20 +16,27 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, provide, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { computed, onMounted, provide, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ConfigProvider } from 'ant-design-vue'
|
||||
import BottomNav from './components/BottomNav.vue'
|
||||
import { cartApi } from './api/cart'
|
||||
import antdLocale from './config/antdv-locale'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const routerReady = ref(false)
|
||||
|
||||
const isHiddenNav = computed(() => {
|
||||
// 检查当前路由及其所有父路由是否有 hideNav: true
|
||||
// 或者检查是否是后台页面
|
||||
const result = route.matched.some(r => r.meta.hideNav) || route.matched.some(r => r.meta.isAdmin)
|
||||
return result
|
||||
if (!routerReady.value) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (route.path === '/' || route.path.startsWith('/admin')) {
|
||||
return true
|
||||
}
|
||||
|
||||
return route.matched.some(r => r.meta.hideNav) || route.matched.some(r => r.meta.isAdmin)
|
||||
})
|
||||
|
||||
// 全局购物车数量状态
|
||||
@@ -74,6 +81,11 @@ watch(() => route.path, async () => {
|
||||
|
||||
// 页面加载时获取购物车数量
|
||||
loadCartCount()
|
||||
|
||||
onMounted(async () => {
|
||||
await router.isReady()
|
||||
routerReady.value = true
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user