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,18 +22,21 @@ function onSidebarScroll(e: Event) {
|
|||||||
'shadow': sidebarScrollTop,
|
'shadow': sidebarScrollTop,
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<!-- 侧边栏模式(无主导航) -->
|
<transition-group name="sub-sidebar">
|
||||||
<el-menu
|
<template v-for="(mainItem, mainIndex) in menuStore.allMenus" :key="mainIndex">
|
||||||
: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="{
|
<div v-show="mainIndex === menuStore.actived">
|
||||||
'is-collapse-without-logo': settingsStore.settings.menu.menuMode !== 'single' && settingsStore.settings.menu.subMenuCollapse,
|
<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">
|
>
|
||||||
<SidebarItem v-if="route.meta?.sidebar !== false" :key="route.path || index" :item="route" :base-path="route.path" />
|
<template v-for="(route, index) in mainItem.children">
|
||||||
</template>
|
<SidebarItem v-if="route.meta?.sidebar !== false" :key="route.path || index" :item="route" :base-path="route.path" />
|
||||||
</transition-group>
|
</template>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</transition-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -73,9 +73,11 @@ const useMenuStore = defineStore(
|
|||||||
}
|
}
|
||||||
// 默认展开的导航路径
|
// 默认展开的导航路径
|
||||||
const defaultOpenedPaths = computed(() => {
|
const defaultOpenedPaths = computed(() => {
|
||||||
let defaultOpenedPaths: string[] = []
|
const defaultOpenedPaths: string[] = []
|
||||||
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
|
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
|
||||||
defaultOpenedPaths = getDefaultOpenedPaths(sidebarMenus.value)
|
allMenus.value.forEach((item) => {
|
||||||
|
defaultOpenedPaths.push(...getDefaultOpenedPaths(item.children))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return defaultOpenedPaths
|
return defaultOpenedPaths
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user