提交 acb4757b authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

fix: 新用户404

上级 5ef6db9d
...@@ -7,7 +7,6 @@ import { getToken } from '@/utils/auth' // get token from cookie ...@@ -7,7 +7,6 @@ import { getToken } from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title' import getPageTitle from '@/utils/get-page-title'
import { buildMenus } from '@/api/system/menu' import { buildMenus } from '@/api/system/menu'
import { filterAsyncRouter } from '@/store/modules/permission' import { filterAsyncRouter } from '@/store/modules/permission'
import { valid } from 'mockjs'
NProgress.configure({ showSpinner: false }) // NProgress Configuration NProgress.configure({ showSpinner: false }) // NProgress Configuration
...@@ -88,7 +87,12 @@ export const loadMenus = (next, to) => { ...@@ -88,7 +87,12 @@ export const loadMenus = (next, to) => {
}) })
}) })
} }
/**
* 验证path是否有效
* @param {*} path
* @param {*} routers
* @returns
*/
const pathValid = (path, routers) => { const pathValid = (path, routers) => {
const temp = path.startsWith('/') ? path.substr(1) : path const temp = path.startsWith('/') ? path.substr(1) : path
const locations = temp.split('/') const locations = temp.split('/')
...@@ -98,17 +102,24 @@ const pathValid = (path, routers) => { ...@@ -98,17 +102,24 @@ const pathValid = (path, routers) => {
return hasCurrentRouter(locations, routers, 0) return hasCurrentRouter(locations, routers, 0)
} }
/**
* 递归验证every level
* @param {*} locations
* @param {*} routers
* @param {*} index
* @returns
*/
const hasCurrentRouter = (locations, routers, index) => { const hasCurrentRouter = (locations, routers, index) => {
const location = locations[index] const location = locations[index]
let kids = [] let kids = []
const valid = routers.some(router => { const isvalid = routers.some(router => {
kids = router.children kids = router.children
return (router.path === location || ('/' + location) === router.path) return (router.path === location || ('/' + location) === router.path)
}) })
if (valid && index < locations.length - 1) { if (isvalid && index < locations.length - 1) {
return hasCurrentRouter(locations, kids, index + 1) return hasCurrentRouter(locations, kids, index + 1)
} }
return valid return isvalid
} }
// 根据权限过滤菜单 // 根据权限过滤菜单
const filterRouter = routers => { const filterRouter = routers => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论