This commit is contained in:
hrx 2025-10-15 17:22:03 +08:00
parent 558eec6013
commit 5b50e00e17
3 changed files with 52 additions and 71 deletions

View File

@ -40,7 +40,7 @@ export default {
name: "Sidebar", name: "Sidebar",
components: { SidebarItem, Logo }, components: { SidebarItem, Logo },
computed: { computed: {
...mapGetters(["permission_routes", "sidebar", "userType", "orgType"]), // orgType ...mapGetters(["permission_routes", "sidebar", "userType", "orgType"]),
showLogo() { showLogo() {
return true; return true;
@ -54,34 +54,15 @@ export default {
return !this.sidebar.opened; return !this.sidebar.opened;
}, },
//
permissionRoutes() { permissionRoutes() {
const routes = this.permission_routes || []; const routes = this.permission_routes || [];
console.log("=== Sidebar 权限路由调试 ===");
console.log("当前权限路由:", routes);
console.log("用户类型:", this.userType);
console.log("组织类型:", this.orgType);
//
const hasOrderManagement = routes.some(route => route.path === '/orderManagement');
const hasResourceManagement = routes.some(route => route.path === '/resourceManagement');
console.log("是否包含订单管理:", hasOrderManagement);
console.log("是否包含资源管理:", hasResourceManagement);
//
console.log("当前用户类型:", this.userType);
console.log("当前组织类型:", this.orgType);
console.log("=== Sidebar 调试结束 ===");
return routes; return routes;
}, },
//
activeMenu() { activeMenu() {
const route = this.$route; const route = this.$route;
const { meta, path } = route; const { meta, path } = route;
// activeMenu使
if (meta.activeMenu) { if (meta.activeMenu) {
return meta.activeMenu; return meta.activeMenu;
} }
@ -92,36 +73,6 @@ export default {
mounted() { mounted() {
console.log("Sidebar mounted - 权限路由:", this.permissionRoutes); console.log("Sidebar mounted - 权限路由:", this.permissionRoutes);
console.log("Sidebar mounted - 用户类型:", this.userType);
console.log("Sidebar mounted - 组织类型:", this.orgType);
console.log("sessionStorage userType:", sessionStorage.getItem('userType'));
console.log("sessionStorage orgType:", sessionStorage.getItem('orgType'));
},
watch: {
permission_routes: {
handler(newRoutes) {
console.log("Sidebar - 权限路由变化:", newRoutes);
},
deep: true,
immediate: true
},
//
userType: {
handler(newType) {
console.log("Sidebar - 用户类型变化:", newType);
},
immediate: true
},
//
orgType: {
handler(newType) {
console.log("Sidebar - 组织类型变化:", newType);
},
immediate: true
}
} }
}; };
</script> </script>
@ -157,6 +108,7 @@ export default {
} }
} }
// -
::v-deep .el-menu-vertical { ::v-deep .el-menu-vertical {
border: none; border: none;
height: 100%; height: 100%;
@ -170,8 +122,36 @@ export default {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
//
.el-menu--inline {
//
.el-menu-item {
//
&.is-active {
background-color: #d7dafd !important;
color: #296ad9 !important;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background-color: #296ad9;
}
} }
//
&:not(.is-active):hover {
background-color: #f5f7fa !important;
}
}
}
}
//
::v-deep .el-menu--collapse { ::v-deep .el-menu--collapse {
width: 64px !important; width: 64px !important;
min-width: 64px !important; min-width: 64px !important;
@ -181,6 +161,16 @@ export default {
text-overflow: clip; text-overflow: clip;
justify-content: center; justify-content: center;
} }
//
.el-menu--popup {
.el-menu-item {
&.is-active {
background-color: #d7dafd !important;
color: #296ad9 !important;
}
}
}
} }
} }
</style> </style>

View File

@ -1,4 +1,5 @@
// / base color // variables.scss
// base color
$blue: #324157; $blue: #324157;
$light-blue: #3A71A8; $light-blue: #3A71A8;
$red: #C03639; $red: #C03639;
@ -9,22 +10,17 @@ $yellow: #FEC171;
$panGreen: #30B08F; $panGreen: #30B08F;
// sidebar // sidebar
$menuText: #000; $menuText: #333;
$menuActiveText: #296ad9; // 当前激活菜单项的文字颜色 $menuActiveText: #296ad9;
$subMenuActiveText: #100101; // 当前激活子菜单项的文字颜色 $subMenuActiveText: #000;
$menuBg: #fff; // 整体背景颜色 $menuBg: #fff;
$menuHover: #f0f0f0; // 鼠标悬浮一级菜单背景色 (轻微变化更友好) $menuHover: #f5f7fa;
$subMenuBg: #f7f7f7; // 子菜单背景色 $subMenuBg: #fff;
$subMenuHover: #eaeaea; // 鼠标悬浮子菜单背景色 (轻微变化更友好) $subMenuHover: #f0f0f0;
$sideBarWidth: 230px; // 侧边栏宽度 $sideBarWidth: 230px;
// Element UI 默认折叠宽度为 64px
// $sideBarCollapseWidth: 64px;
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
:export { :export {
menuText: $menuText; menuText: $menuText;
menuActiveText: $menuActiveText; menuActiveText: $menuActiveText;
@ -34,9 +30,4 @@ $sideBarWidth: 230px; // 侧边栏宽度
subMenuBg: $subMenuBg; subMenuBg: $subMenuBg;
subMenuHover: $subMenuHover; subMenuHover: $subMenuHover;
sideBarWidth: $sideBarWidth; sideBarWidth: $sideBarWidth;
// sideBarCollapseWidth: $sideBarCollapseWidth;
} }