[bug] - 修改线上所领导不能单点登录的bug

This commit is contained in:
fengchenchen
2022-05-16 13:45:46 +08:00
parent c24e9cadbc
commit e3f4a058cb
2 changed files with 23 additions and 1 deletions
+9 -1
View File
@@ -6,6 +6,7 @@ import 'nprogress/nprogress.css' // progress bar style
// import notification from 'ant-design-vue/es/notification'
import { ACCESS_TOKEN, INDEX_MAIN_PAGE_PATH,USER_INFO } from '@/store/mutation-types'
import { generateIndexRouter } from '@/utils/util'
import { menuPermission } from './utils/hasPermission'
import {loginIdmPlatform} from '@api/api'
import {notification} from 'ant-design-vue'
@@ -64,7 +65,14 @@ router.beforeEach(async (to, from, next) => {
// 根据roles权限生成可访问的路由表
// 动态添加可访问路由表
router.addRoutes(store.getters.addRouters)
const redirect = decodeURIComponent(from.query.redirect || to.path)
let redirect = decodeURIComponent(from.query.redirect || to.path)
let opeMenuData = JSON.parse(JSON.stringify(menuData))
if(!menuPermission(opeMenuData, redirect)) {
const firstRouter = constRoutes[0].redirect
redirect = firstRouter
}
// const redirect = decodeURIComponent(from.query.redirect || to.path)
if (to.path === redirect) {
// hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
next({ ...to, replace: true })
+14
View File
@@ -199,5 +199,19 @@ export function judgeGlobalPermission(bindingValue) {
return true
}
/*判断是否有菜单的权限*/
export function menuPermission(menuData, routePath) {
let accessedRouters = menuData.some(route => {
if (route.path !== routePath) {
if (route.children && route.children.length) {
return menuPermission(route.children, routePath)
}
return false
}
return true
})
return accessedRouters
}
export default hasPermission