提交 2be30278 authored 作者: pengxiaohui's avatar pengxiaohui

权限控制

上级 6ca00859
...@@ -44,7 +44,8 @@ httpRequest.interceptors.response.use( ...@@ -44,7 +44,8 @@ httpRequest.interceptors.response.use(
return Promise.reject(data) return Promise.reject(data)
} }
if (data.code === 403) { if (data.code === 403) {
router.push('/error-page/401') // router.push('/error-page/401')
window.location.href = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}`
} }
return data return data
}, },
......
import store from '@/store' import store from '@/store'
// import router, { resetRouter } from '@/router' import router, { resetRouter } from '@/router'
export default class BeforeEnter { export default class BeforeEnter {
constructor(opt) { constructor(opt) {
this.opt = opt || {} this.opt = opt || {}
...@@ -11,26 +11,26 @@ export default class BeforeEnter { ...@@ -11,26 +11,26 @@ export default class BeforeEnter {
window.location.href = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}` window.location.href = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}`
return return
} else { } else {
// const hasPermissions = store.state.user.permissions && store.state.user.permissions.length > 0 const hasPermissions = store.state.user.permissions && store.state.user.permissions.length > 0
// if (hasPermissions) { if (hasPermissions) {
// next() next()
// } else { } else {
// try { try {
// await store.dispatch('checkRolesPermissions') await store.dispatch('checkRolesPermissions')
// const permissions = store.state.user.permissions const permissions = store.state.user.permissions
// // 基于权限获取可接入的路由 // 基于权限获取可接入的路由
// const accessRoutes = await store.dispatch('permission/routesByPermissions', permissions) const accessRoutes = await store.dispatch('permission/routesByPermissions', permissions)
// // 重新设置路由 // 重新设置路由
// resetRouter() resetRouter()
// // dynamically add accessible routes // dynamically add accessible routes
// router.addRoutes(accessRoutes) router.addRoutes(accessRoutes)
// // hack method to ensure that addRoutes is complete // hack method to ensure that addRoutes is complete
// // set the replace: true, so the navigation will not leave a history record // set the replace: true, so the navigation will not leave a history record
// next({ ...to, replace: true }) next({ ...to, replace: true })
// } catch (error) { } catch (error) {
// next() next()
// } }
// } }
} }
// store.dispatch('setUserRoles') // store.dispatch('setUserRoles')
next() next()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论