整合数据
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
<!-- 菜单主体 -->
|
||||
<el-menu
|
||||
v-else
|
||||
:collapse="isCollapse"
|
||||
:collapse-transition="false"
|
||||
:background-color="asideBgColor"
|
||||
@@ -23,6 +22,7 @@
|
||||
:active-background-color="activeBgColor"
|
||||
class="el-menu-vertical-demo"
|
||||
:unique-opened="true"
|
||||
:default-openeds="defaultOpeneds"
|
||||
@select="handleMenuSelect"
|
||||
:default-active="route.path"
|
||||
>
|
||||
@@ -284,10 +284,29 @@ const currentModule = computed(() => {
|
||||
});
|
||||
|
||||
const displayMenus = computed(() => {
|
||||
// 侧边栏始终展示完整菜单树,不随当前路由切换为“子菜单视图”
|
||||
// 侧边栏始终展示完整菜单树,不随当前路由切换为"子菜单视图"
|
||||
return list.value;
|
||||
});
|
||||
|
||||
const findOpenMenuPaths = (menus, targetPath, ancestors = []) => {
|
||||
for (const menu of menus) {
|
||||
const currentPath = menu.path || menu.id.toString();
|
||||
if (menu.path && (targetPath === menu.path || targetPath.startsWith(menu.path + "/"))) {
|
||||
return [...ancestors, currentPath];
|
||||
}
|
||||
if (menu.children && menu.children.length > 0) {
|
||||
const found = findOpenMenuPaths(menu.children, targetPath, [...ancestors, currentPath]);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const defaultOpeneds = computed(() => {
|
||||
const result = findOpenMenuPaths(displayMenus.value, route.path);
|
||||
return result || [];
|
||||
});
|
||||
|
||||
const asideTitle = computed(() => {
|
||||
if (isCollapse.value) return "管理";
|
||||
return "菜单";
|
||||
@@ -311,7 +330,7 @@ const processMenus = (menus) => {
|
||||
.map((menu) => ({
|
||||
id: menu.id,
|
||||
path: menu.path,
|
||||
icon: menu.icon || "Document",
|
||||
icon: menu.icon || null,
|
||||
title: menu.title,
|
||||
route: menu.path,
|
||||
component_path: menu.component_path,
|
||||
@@ -541,13 +560,13 @@ h3 {
|
||||
// 高亮样式
|
||||
.el-menu-item.is-active {
|
||||
html:not(.dark) & {
|
||||
background-color: rgba(57, 115, 255, 0.3) !important;
|
||||
background-color: rgba(255, 255, 255, 0.2) !important;
|
||||
border-left: 3px solid #ffffff;
|
||||
}
|
||||
html.dark & {
|
||||
background-color: rgba(60, 60, 60, 0.8) !important;
|
||||
}
|
||||
color: #ffffff !important;
|
||||
border-left: 3px solid #4f84ff;
|
||||
margin-left: -3px;
|
||||
|
||||
.menu-icon {
|
||||
@@ -574,12 +593,17 @@ h3 {
|
||||
}
|
||||
|
||||
&.is-opened .el-sub-menu__title {
|
||||
background: rgba(255, 255, 255, 0.08) !important;
|
||||
background: rgba(255, 255, 255, 0.12) !important;
|
||||
margin-left: -3px;
|
||||
}
|
||||
|
||||
.el-menu-item {
|
||||
padding-left: 48px !important;
|
||||
font-size: 13px;
|
||||
|
||||
&.is-active {
|
||||
background: rgba(255, 255, 255, 0.18) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,6 +628,10 @@ h3 {
|
||||
.el-sub-menu.is-opened .el-sub-menu__title {
|
||||
background: rgba(64, 158, 255, 0.08) !important;
|
||||
}
|
||||
|
||||
.el-sub-menu .el-menu-item.is-active {
|
||||
background: rgba(64, 158, 255, 0.15) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user