Commit fef1e967 authored by 张伯涛's avatar 张伯涛

修改

parent 31f4e7e1
...@@ -38,7 +38,7 @@ router.beforeEach((to, from, next) => { ...@@ -38,7 +38,7 @@ router.beforeEach((to, from, next) => {
router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表 router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
} else { } else {
alert('用户无权限1') alert('用户无权限')
store.dispatch('FedLogOut').then(() => { store.dispatch('FedLogOut').then(() => {
next({ path: '/' }) next({ path: '/' })
// window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}` // window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}`
...@@ -46,7 +46,7 @@ router.beforeEach((to, from, next) => { ...@@ -46,7 +46,7 @@ router.beforeEach((to, from, next) => {
} }
}) })
} else { } else {
alert('用户无权限2') alert('用户无权限')
store.dispatch('FedLogOut').then(() => { store.dispatch('FedLogOut').then(() => {
next({ path: '/' }) next({ path: '/' })
// window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}` // window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}`
......
...@@ -20,21 +20,31 @@ const permission = { ...@@ -20,21 +20,31 @@ const permission = {
return new Promise(resolve => { return new Promise(resolve => {
// 向后端请求路由数据 // 向后端请求路由数据
// getInfo().then(res => { // getInfo().then(res => {
const accessedRoutes = filterAsyncRouter(res.data.menus[0].children) const pathList = res.data.menus.map(item => item.path).join(',').split(',')
console.log('进来了', accessedRoutes) console.log('pathList', pathList)
for (let i = 0, l = res.data.menus[0].children.length; i < l; i++) { if (pathList.includes('nlt_pc')) {
if (res.data.menus[0].children[i].path === '/entry') { for (let i = 0, l = res.data.menus.length; i < l; i++) {
res.data.menus[0].children[i].showFather = 'false' if (res.data.menus[i].path === 'nlt_pc') {
const accessedRoutes = filterAsyncRouter(res.data.menus[i].children)
const newRouters = res.data.menus[i].path // 当前用户pc端的菜单权限
console.log('进来了', accessedRoutes)
for (let j = 0, l = res.data.menus[i].children.length; j < l; j++) {
res.data.menus[i].children[j].showFather = 'false'
}
if (accessedRoutes[0]) {
const firstChild = getFirstChild(accessedRoutes[0])
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
accessedRoutes.push({ path: '/', redirect: firstChild, hidden: true })
commit('SET_ROUTES', accessedRoutes)
}
const routers = { accessedRoutes: accessedRoutes, getRouters: newRouters }
resolve(routers)
}
} }
} else {
const routers = { accessedRoutes: [], getRouters: [] }
resolve(routers)
} }
if (accessedRoutes[0]) {
const firstChild = getFirstChild(accessedRoutes[0])
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
accessedRoutes.push({ path: '/', redirect: firstChild, hidden: true })
commit('SET_ROUTES', accessedRoutes)
}
const routers = { accessedRoutes: accessedRoutes, getRouters: res.data.menus[1].children }
resolve(routers)
// }) // })
}) })
} }
......
...@@ -95,6 +95,7 @@ const user = { ...@@ -95,6 +95,7 @@ const user = {
FedLogOut({ commit }) { FedLogOut({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', [])
removeToken() removeToken()
resolve() resolve()
}) })
......
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