|
|
@ -6,8 +6,8 @@
|
|
|
|
mode="horizontal"
|
|
|
|
mode="horizontal"
|
|
|
|
router
|
|
|
|
router
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<template v-for="item in routeItem">
|
|
|
|
<template v-for="item in processedRouteItems">
|
|
|
|
<template v-if="item.subs">
|
|
|
|
<template v-if="item.subs && item.show">
|
|
|
|
<el-submenu :index="item.path" :key="item.path">
|
|
|
|
<el-submenu :index="item.path" :key="item.path">
|
|
|
|
<template slot="title">
|
|
|
|
<template slot="title">
|
|
|
|
<span slot="title">{{ item.name }}</span>
|
|
|
|
<span slot="title">{{ item.name }}</span>
|
|
|
@ -19,7 +19,7 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-submenu>
|
|
|
|
</el-submenu>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<template v-else-if="item.show">
|
|
|
|
<el-menu-item :index="item.path" :key="item.path">
|
|
|
|
<el-menu-item :index="item.path" :key="item.path">
|
|
|
|
<span slot="title">{{ item.name }}</span>
|
|
|
|
<span slot="title">{{ item.name }}</span>
|
|
|
|
</el-menu-item>
|
|
|
|
</el-menu-item>
|
|
|
@ -115,8 +115,24 @@ export default {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
rawMenus: "",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
|
|
processedRouteItems() {
|
|
|
|
|
|
|
|
// 将 rawMenus 转换为布尔值数组
|
|
|
|
|
|
|
|
const menus = this.rawMenus.split(",").map(Number);
|
|
|
|
|
|
|
|
// 处理 routeItems,添加 show 属性
|
|
|
|
|
|
|
|
return this.routeItem.map((item, index) => {
|
|
|
|
|
|
|
|
// 如果 item 没有 show 属性,则添加它
|
|
|
|
|
|
|
|
if (!item.hasOwnProperty("show")) {
|
|
|
|
|
|
|
|
return { ...item, show: menus[index] };
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return { ...item, show: item.show && menus[index] }; // 逻辑与,两者都为真时才显示
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
console.log(window.location.host);
|
|
|
|
console.log(window.location.host);
|
|
|
|
console.log(process.env.NODE_ENV);
|
|
|
|
console.log(process.env.NODE_ENV);
|
|
|
@ -152,6 +168,8 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
created() {
|
|
|
|
|
|
|
|
this.rawMenus = localStorage.getItem("menus") || "1,1,1,1,0,0,0"; // 提供一个默认值以防没有数据
|
|
|
|
|
|
|
|
console.log(this.menus);
|
|
|
|
this.setCurrentRoute();
|
|
|
|
this.setCurrentRoute();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|