fix: 移除模板代码中的 $route

This commit is contained in:
Hooray Hu 2023-05-13 01:59:50 +08:00
parent d4c465734f
commit 84e0630dd0
2 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,8 @@ defineOptions({
name: 'SubSidebar',
})
const route = useRoute()
const settingsStore = useSettingsStore()
const menuStore = useMenuStore()
@ -30,12 +32,12 @@ function onSidebarScroll(e: Event) {
<template v-for="(mainItem, mainIndex) in menuStore.allMenus" :key="mainIndex">
<div v-show="mainIndex === menuStore.actived">
<el-menu
:unique-opened="settingsStore.settings.menu.subMenuUniqueOpened" :default-openeds="menuStore.defaultOpenedPaths" :default-active="$route.meta.activeMenu || $route.path" :collapse="settingsStore.mode === 'pc' && settingsStore.settings.menu.subMenuCollapse" :collapse-transition="false" :class="{
:unique-opened="settingsStore.settings.menu.subMenuUniqueOpened" :default-openeds="menuStore.defaultOpenedPaths" :default-active="route.meta.activeMenu || route.path" :collapse="settingsStore.mode === 'pc' && settingsStore.settings.menu.subMenuCollapse" :collapse-transition="false" :class="{
'is-collapse-without-logo': settingsStore.settings.menu.menuMode !== 'single' && settingsStore.settings.menu.subMenuCollapse,
}"
>
<template v-for="(route, index) in mainItem.children">
<SidebarItem v-if="route.meta?.sidebar !== false" :key="route.path || index" :item="route" :base-path="route.path" />
<template v-for="(item, index) in mainItem.children">
<SidebarItem v-if="item.meta?.sidebar !== false" :key="item.path || index" :item="item" :base-path="item.path" />
</template>
</el-menu>
</div>

View File

@ -74,7 +74,7 @@ onUnmounted(() => {
<SubSidebar />
</div>
<div class="sidebar-mask" :class="{ show: settingsStore.mode === 'mobile' && !settingsStore.settings.menu.subMenuCollapse }" @click="settingsStore.toggleSidebarCollapse()" />
<div class="main-container" :style="{ 'padding-bottom': $route.meta.paddingBottom } as any">
<div class="main-container" :style="{ 'padding-bottom': routeInfo.meta.paddingBottom } as any">
<Topbar v-if="!(settingsStore.settings.menu.menuMode === 'head' && !settingsStore.settings.menu.enableSubMenuCollapseButton && !settingsStore.settings.breadcrumb.enable)" />
<div class="main">
<router-view v-slot="{ Component, route }">