外部用户权限控制

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

@@ -6,7 +6,7 @@
<img src="../assets/logo/logo-white.png" v-if="textColor == '#fff' || textColor == '#ffffff'" style="width:160px;height: 27px;" />
<img src="../assets/logo/logo.png" v-else style="width:160px;height: 27px;" />
</div>
<div class="portal-top-nav">
<div class="portal-top-nav" v-if="userInfo.role === 1">
<div class="top-nav" :style="{color:textColor}" :class="current == 'index' ? activeNav : ''">
<router-link to="/index" >首页
<div :class="current == 'index' ? 'nav-bottbor' : ''"></div>
@@ -65,7 +65,7 @@
</div>
</div>
<div class="portal-top-right">
<div v-if="goSearch !=10" style="position: relative;">
<div v-if="goSearch !=10 && userInfo.role === 1" style="position: relative;">
<el-input class="portal-input" v-show="!hideSearch" placeholder="搜索全部" style="border-radius: 20px !important; " @keyup.enter.native="searchJump()" clearable maxlength="50" v-model="keyword" >
<el-select v-if="current == 'index'" v-model="findType" style="width: 75px; border-radius:20px !important;" slot="prepend" placeholder="请选择">
<el-option label="课程" value="1"></el-option>
@@ -208,6 +208,7 @@ export default {
this.sex = this.userInfo.sex;
this.$store.dispatch('refrashMsg');
this.loadBoeData();
console.log('this.userInfo::',this.userInfo)
//this.loadPopupConfig();
},
methods: {

View File

@@ -6,7 +6,7 @@
<div class="xtop-logo">
<router-link class="routerLink" to="/index"><img src="../../../assets/logo/logo-white.png" style="width:161px;height:27px;" /></router-link>
</div>
<div class="xtop-nav">
<div class="xtop-nav" v-if="userInfo.role === 1">
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/index`">首页</a></div>
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/course`">课程</a></div>
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/case`">案例</a></div>

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);

View File

@@ -41,6 +41,10 @@ const user = {
sessionStorage.setItem("curIdentity", iden);
},
SET_UserInfo: (state, uinfo) => {
// 内部用户和外部用户测试用
uinfo.role = uinfo.departFullName.indexOf('京东方科技集团股份有限公司')!=-1?1:2
if(uinfo.name === '尹晓钦') uinfo.role = 2
console.log('uinfo::',uinfo)
state.info = uinfo
},
SET_PERMISSIONS: (state, permissions) => {