Commit 3268c1d6 authored by Wallen姚文辉's avatar Wallen姚文辉

修复不存在路径会无限循环的问题

parent 7a630bd7
...@@ -90,10 +90,15 @@ router.beforeEach(async (to, from, next) => { ...@@ -90,10 +90,15 @@ router.beforeEach(async (to, from, next) => {
} }
} }
const findMenu = (menu, each) => { const findMenu = (menu, each) => {
for (let ele in menu) {
if (ele.router == each) return true menu.forEach(element => {
if (ele.children) return findMenu(ele.children, each) if (element.router == each && each) return true
} if (element.children && findMenu(element.children)) return true
});
// for (let ele of menu) {
// if (ele.router == each) return true
// if (ele.children) return findMenu(ele.children, each)
// }
} }
if (to.path == '/login') return next(); if (to.path == '/login') return next();
if (localStorage.getItem('token')) { if (localStorage.getItem('token')) {
...@@ -107,8 +112,6 @@ router.beforeEach(async (to, from, next) => { ...@@ -107,8 +112,6 @@ router.beforeEach(async (to, from, next) => {
const menu = userinfo.menu const menu = userinfo.menu
if (findMenu(menu, to.name) && !router.hasRoute(to.name)) { if (findMenu(menu, to.name) && !router.hasRoute(to.name)) {
a(menu) a(menu)
// console.info(router.getRoutes())
console.info(to)
return next(to) return next(to)
} }
return next() return next()
...@@ -123,7 +126,6 @@ function request(method, url, data, apply, successFun = () => { }, failFun = () ...@@ -123,7 +126,6 @@ function request(method, url, data, apply, successFun = () => { }, failFun = ()
if (method != "get" && apply) apply.$Message.success(data.message); if (method != "get" && apply) apply.$Message.success(data.message);
successFun(res.data) successFun(res.data)
}).catch(error => { }).catch(error => {
console.info(error)
try { try {
if (error.response.data.code == 401) { if (error.response.data.code == 401) {
apply.$Message.error(error.response.data.message); apply.$Message.error(error.response.data.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment