feat: 菜单新增 active_menu 字段

This commit is contained in:
JaguarJack
2023-03-01 15:11:53 +08:00
parent b81d4796ff
commit bcf3d9ec34
11 changed files with 145 additions and 103 deletions

View File

@@ -19,9 +19,9 @@ const breadcrumbs = ref<string[]>([])
// 监听当前路由的变化
watch(router.currentRoute, (newValue, oldValue) => {
// 如果是内页,则不切换激活菜单
if (newValue.meta.is_inner === undefined || !newValue.meta.is_inner) {
appStore.setActiveMenu(newValue.path)
// 激活菜单
if (newValue.meta.active_menu) {
appStore.setActiveMenu(newValue.meta.active_menu)
}
getBreadcrumbs(newValue)
})
@@ -29,7 +29,12 @@ watch(router.currentRoute, (newValue, oldValue) => {
// get init breadcrumb
onMounted(() => {
if (router.currentRoute.value.path !== '/') {
appStore.setActiveMenu(router.currentRoute.value.path)
// 如果是内页,并且设置激活菜单
if (router.currentRoute.value.meta.active_menu) {
appStore.setActiveMenu(router.currentRoute.value.meta.active_menu)
} else {
appStore.setActiveMenu(router.currentRoute.value.path)
}
}
getBreadcrumbs(router.currentRoute.value)