| | |
| | | class="sidebar-container-wrapper" |
| | | > |
| | | <el-scrollbar :class="sideTheme" wrap-class="scrollbar-wrapper" view-class="scrollbar-view"> |
| | | <!-- 首页时不显示任何菜单项 --> |
| | | <!-- 始终显示菜单项,不再根据路径判断 --> |
| | | <el-menu |
| | | v-if="!isHomePage" |
| | | :default-active="activeMenu" |
| | | :collapse="isCollapse" |
| | | :background-color="'transparent'" |
| | |
| | | mode="vertical" |
| | | class="custom-menu" |
| | | > |
| | | <sidebar-item |
| | | v-for="(route, index) in sidebarRouters" |
| | | :key="route.path + index" |
| | | :item="route" |
| | | :base-path="route.path" |
| | | /> |
| | | <!-- 当前是首页看板子路由时,渲染专用路由 --> |
| | | <template v-if="isIndexSubRoute"> |
| | | <sidebar-item |
| | | v-for="(route, index) in indexPageRouters" |
| | | :key="route.path + index" |
| | | :item="route" |
| | | :base-path="route.path" |
| | | /> |
| | | </template> |
| | | <template v-else> |
| | | <sidebar-item |
| | | v-for="(route, index) in sidebarRouters" |
| | | :key="route.path + index" |
| | | :item="route" |
| | | :base-path="route.path" |
| | | /> |
| | | </template> |
| | | </el-menu> |
| | | <!-- 首页时的空白区域 --> |
| | | <div v-else class="home-empty-menu"></div> |
| | | </el-scrollbar> |
| | | |
| | | <!-- 底部用户区域 --> |
| | |
| | | |
| | | const sidebarRouters = computed(() => permissionStore.sidebarRouters) |
| | | |
| | | // 判断当前是否为首页 |
| | | const isHomePage = computed(() => { |
| | | return route.path === '/index' || route.path === '/' || route.fullPath.startsWith('/index') |
| | | // 判断当前是否为首页子路由(/index/index) |
| | | const isIndexSubRoute = computed(() => { |
| | | return route.path === '/index/index' |
| | | }) |
| | | |
| | | // 首页专用路由,只有首页一个菜单项 |
| | | const homePageRouters = computed(() => { |
| | | // 从原始路由中筛选出首页路由 |
| | | const homeRoute = sidebarRouters.value.find(route => { |
| | | return route.children && route.children.find(child => child.path === '/index') |
| | | }) |
| | | |
| | | return homeRoute ? [homeRoute] : [] |
| | | // 判断当前是否为主首页路由(/index或/) |
| | | const isMainIndexRoute = computed(() => { |
| | | return route.path === '/index' || route.path === '/' |
| | | }) |
| | | |
| | | // 首页专用路由,首页看板相关菜单 |
| | | const indexPageRouters = computed(() => { |
| | | // 查找name为Index的路由 |
| | | const indexRoute = sidebarRouters.value.find(route => route.name === 'Index') |
| | | return indexRoute ? [indexRoute] : [] |
| | | }) |
| | | |
| | | const showLogo = computed(() => settingsStore.sidebarLogo) |