|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div v-if="!item.hidden" class="menu-wrapper">
|
|
|
+ <div v-if="!item.hidden" v-show="menuIsShow(item)" class="menu-wrapper">
|
|
|
<template
|
|
|
v-if="
|
|
|
hasOneShowingChild(item.children, item) &&
|
|
@@ -52,7 +52,7 @@ import { isExternal } from "@/utils/validate";
|
|
|
import Item from "./Item";
|
|
|
import AppLink from "./Link";
|
|
|
import FixiOSBug from "./FixiOSBug";
|
|
|
-
|
|
|
+import { getBelongTopMenuPath } from '@/utils/permission';
|
|
|
export default {
|
|
|
name: "SidebarItem",
|
|
|
components: { Item, AppLink },
|
|
@@ -71,6 +71,10 @@ export default {
|
|
|
type: String,
|
|
|
default: "",
|
|
|
},
|
|
|
+ activeTopMenu: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
},
|
|
|
data() {
|
|
|
// To fix https://github.com/PanJiaChen/vue-admin-template/issues/237
|
|
@@ -81,7 +85,33 @@ export default {
|
|
|
mounted() {
|
|
|
this.onlyOneChild = null;
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ getActiveTopMenu: function () {
|
|
|
+ if (this.activeTopMenu !== '') {
|
|
|
+ return this.activeTopMenu;
|
|
|
+ }
|
|
|
+ const route = this.$route;
|
|
|
+ /*
|
|
|
+ const { meta, path } = route;
|
|
|
+ if (meta.belongTopMenu) {
|
|
|
+ return meta.belongTopMenu;
|
|
|
+ }
|
|
|
+ return '/' + path.split('/')[1];
|
|
|
+ */
|
|
|
+ return getBelongTopMenuPath(route);
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ menuIsShow(route) {
|
|
|
+ let activeTopMenu = this.basePath;
|
|
|
+ const { meta } = route;
|
|
|
+ if (meta.belongTopMenu) {
|
|
|
+ activeTopMenu = meta.belongTopMenu;
|
|
|
+ }
|
|
|
+ //
|
|
|
+ // console.log(activeTopMenu, this.getActiveTopMenu)
|
|
|
+ return activeTopMenu === this.getActiveTopMenu;
|
|
|
+ },
|
|
|
hasOneShowingChild(children = [], parent) {
|
|
|
const showingChildren = children.filter((item) => {
|
|
|
if (item.hidden) {
|