外部用户权限控制

This commit is contained in:
joshen
2024-07-11 21:32:47 +08:00
parent 9b0525994a
commit 8cca156955
4 changed files with 20 additions and 5 deletions

View File

@@ -24,16 +24,26 @@ router.beforeEach((to, from, next) => {
}
NProgress.start();
// console.log('whiteList::',whiteList,to.path)
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
}else{
if(getToken()){
if(to.path === '/login'){
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/index' })
// 如果是外部用户,把配置的路由跳转到个人中心
if(store.getters.userInfo.role === 2){
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/uc/study/courses' })
}else{
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/index' })
}
NProgress.done();
} else {
//console.log('store.getters.userInfo:',store.getters.userInfo.role)
// 如果是外部用户,把配置的路由跳转到个人中心
if(store.getters.userInfo.role === 2){
if(to.path === '/index' || to.path === '/course' || to.path === '/case' || to.path === '/article' ) location.href = '/pc/uc/study/task'
}
//后续这里需要增加一定的控制
if (!store.getters.init) {
sessionStorage.removeItem(xpage.constants.localCaseFiltersKey);