mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-05 13:37:45 +08:00
重构次导航默认展开效果
This commit is contained in:
parent
2ffc8fe59d
commit
136d2cf216
@ -22,19 +22,22 @@ function onSidebarScroll(e: Event) {
|
||||
'shadow': sidebarScrollTop,
|
||||
}"
|
||||
/>
|
||||
<!-- 侧边栏模式(无主导航) -->
|
||||
<transition-group name="sub-sidebar">
|
||||
<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="{
|
||||
'is-collapse-without-logo': settingsStore.settings.menu.menuMode !== 'single' && settingsStore.settings.menu.subMenuCollapse,
|
||||
}"
|
||||
>
|
||||
<transition-group name="sub-sidebar">
|
||||
<template v-for="(route, index) in menuStore.sidebarMenus">
|
||||
<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>
|
||||
</transition-group>
|
||||
</el-menu>
|
||||
</div>
|
||||
</template>
|
||||
</transition-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -73,9 +73,11 @@ const useMenuStore = defineStore(
|
||||
}
|
||||
// 默认展开的导航路径
|
||||
const defaultOpenedPaths = computed(() => {
|
||||
let defaultOpenedPaths: string[] = []
|
||||
const defaultOpenedPaths: string[] = []
|
||||
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
|
||||
defaultOpenedPaths = getDefaultOpenedPaths(sidebarMenus.value)
|
||||
allMenus.value.forEach((item) => {
|
||||
defaultOpenedPaths.push(...getDefaultOpenedPaths(item.children))
|
||||
})
|
||||
}
|
||||
return defaultOpenedPaths
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user