diff --git a/src/page/index/sidebar/sidebarItem.vue b/src/page/index/sidebar/sidebarItem.vue
index 138977d6..ed56a21f 100644
--- a/src/page/index/sidebar/sidebarItem.vue
+++ b/src/page/index/sidebar/sidebarItem.vue
@@ -10,12 +10,12 @@
{{item.label}}
-
-
+
+
{{child.label}}
-
+
diff --git a/src/permission.js b/src/permission.js
index a3bbd8f3..6f85e821 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -13,7 +13,7 @@ const whiteList = ['/login', '/404', '/401']
const lockPage = '/lock'
router.addRoutes(asyncRouterMap); // 动态添加可访问路由表
router.beforeEach((to, from, next) => {
- store.commit('SET_TAG', from.query.src ? from.query.src : from.path);
+ store.commit('SET_TAG', to.query.src ? to.query.src : to.path);
if (store.getters.access_token) { // determine if there has token
/* has token*/
if (store.getters.isLock && to.path != lockPage) {
@@ -45,47 +45,44 @@ router.beforeEach((to, from, next) => {
})
//寻找子菜单的父类
-function findMenuParent(tagCurrent, tag, tagWel) {
- let index = -1;
- tagCurrent.forEach((ele, i) => {
- if (ele.value == tag.value) {
- index = i;
+function findMenuParent(tag) {
+ let tagCurrent = [];
+ const menu = store.getters.menu;
+ //如果是一级菜单直接返回
+ menu.forEach(ele => {
+ if (ele.path == tag.value) {
+ tagCurrent.push(tag);
+ return tagCurrent;
}
- })
- if (tag.value == tagWel.value) {//判断是否为首页
- tagCurrent = [tagWel];
- } else if (index != -1) {//判断是否存在了
- tagCurrent.splice(index, tagCurrent.length - 1);
- } else {//其他操作
- console.log(store.getters.menu)
- let currentPathObj = store.getters.menu.filter(item => {
- if (item.children.length == 1) {
- return item.children[0].href === tag.value;
- } else {
- let i = 0;
- let childArr = item.children;
- let len = childArr.length;
- while (i < len) {
- if (childArr[i].path === tag.value) {
- return true;
- }
- i++;
+ });
+
+ let currentPathObj = menu.filter(item => {
+ if (item.children.length == 1) {
+ return item.children[0].path === tag.value;
+ } else {
+ let i = 0;
+ let childArr = item.children;
+ let len = childArr.length;
+ while (i < len) {
+ if (childArr[i].path === tag.value) {
+ return true;
+ break;
}
- return false;
+ i++;
}
- })[0];
- tagCurrent = [tagWel];
- validatenull(currentPathObj) ? '' : tagCurrent.push(currentPathObj);
- tagCurrent.push(tag);
- }
+ return false;
+ }
+ })[0];
+ tagCurrent.push(currentPathObj);
+ tagCurrent.push(tag);
return tagCurrent;
+
}
router.afterEach((to, from) => {
setTimeout(() => {
const tag = store.getters.tag;
- const tagWel = store.getters.tagWel;
let tagCurrent = store.getters.tagCurrent;
setTitle(tag.label);
- store.commit('SET_TAG_CURRENT', findMenuParent(tagCurrent, tag, tagWel));
+ store.commit('SET_TAG_CURRENT', findMenuParent(tag));
}, 0);
})
\ No newline at end of file
diff --git a/src/store/modules/tags.js b/src/store/modules/tags.js
index 4478024e..dcaeef7b 100644
--- a/src/store/modules/tags.js
+++ b/src/store/modules/tags.js
@@ -25,10 +25,7 @@ const navs = {
label: "首页",
value: "/wel/index"
},
- tagCurrent: getStore({ name: 'tagCurrent' }) || [{
- label: "首页",
- value: "/wel/index"
- }],
+ tagCurrent: getStore({ name: 'tagCurrent' }) || [],
},
actions: {