pms-aomei/src/views/main-sidebar.vue

68 lines
1.5 KiB
Vue
Raw Normal View History

2023-01-16 11:08:54 +08:00
<!--
* @Author: zwq
* @Date: 2023-01-04 10:29:40
* @LastEditors: zwq
* @LastEditTime: 2023-01-05 15:52:01
* @Description:
-->
<template>
<aside
:class="['aui-sidebar', `aui-sidebar--${$store.state.sidebarLayoutSkin}`]"
>
<div class="aui-sidebar__inner">
<el-menu
:default-active="$store.state.sidebarMenuActiveName"
:collapse="$store.state.sidebarFold"
:unique-opened="true"
:collapseTransition="false"
class="aui-sidebar__menu"
>
<sub-menu
v-for="menu in $store.state.sidebarMenuList"
:key="menu.id"
:menu="menu"
/>
</el-menu>
</div>
</aside>
</template>
<script>
import SubMenu from "./main-sidebar-sub-menu";
export default {
data() {
return {};
},
components: {
SubMenu,
},
created() {
this.$store.state.sidebarMenuList = this.getUnhiddenRoutesListFrom(
window.SITE_CONFIG["menuList"]
);
},
methods: {
getUnhiddenRoutesListFrom(fullList) {
const list = [];
if (fullList.length) {
fullList.forEach((menu) => {
if (menu.sort !== 99) {
/** 前后端约定,路由排序值为 99 时不在前端的侧边栏展示该路由 */
const newRouteItem = JSON.parse(JSON.stringify(menu));
if (menu.children) {
newRouteItem.children = this.getUnhiddenRoutesListFrom(
menu.children
);
}
list.push(newRouteItem);
} else {
// console.log(menu.name, '是应该被隐藏的路由')
}
});
}
return list;
},
},
};
</script>