mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-12 04:16:45 +08:00
外部用户权限控制
This commit is contained in:
@@ -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-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;" />
|
<img src="../assets/logo/logo.png" v-else style="width:160px;height: 27px;" />
|
||||||
</div>
|
</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 : ''">
|
<div class="top-nav" :style="{color:textColor}" :class="current == 'index' ? activeNav : ''">
|
||||||
<router-link to="/index" >首页
|
<router-link to="/index" >首页
|
||||||
<div :class="current == 'index' ? 'nav-bottbor' : ''"></div>
|
<div :class="current == 'index' ? 'nav-bottbor' : ''"></div>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="portal-top-right">
|
<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-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-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>
|
<el-option label="课程" value="1"></el-option>
|
||||||
@@ -208,6 +208,7 @@ export default {
|
|||||||
this.sex = this.userInfo.sex;
|
this.sex = this.userInfo.sex;
|
||||||
this.$store.dispatch('refrashMsg');
|
this.$store.dispatch('refrashMsg');
|
||||||
this.loadBoeData();
|
this.loadBoeData();
|
||||||
|
console.log('this.userInfo::',this.userInfo)
|
||||||
//this.loadPopupConfig();
|
//this.loadPopupConfig();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="xtop-logo">
|
<div class="xtop-logo">
|
||||||
<router-link class="routerLink" to="/index"><img src="../../../assets/logo/logo-white.png" style="width:161px;height:27px;" /></router-link>
|
<router-link class="routerLink" to="/index"><img src="../../../assets/logo/logo-white.png" style="width:161px;height:27px;" /></router-link>
|
||||||
</div>
|
</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}/index`">首页</a></div>
|
||||||
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/course`">课程</a></div>
|
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/course`">课程</a></div>
|
||||||
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/case`">案例</a></div>
|
<div class="xtop-nav-item"><a :href="`${webBaseUrl}/case`">案例</a></div>
|
||||||
|
|||||||
@@ -24,16 +24,26 @@ router.beforeEach((to, from, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
|
// console.log('whiteList::',whiteList,to.path)
|
||||||
if (whiteList.indexOf(to.path) !== -1) {
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
// 在免登录白名单,直接进入
|
// 在免登录白名单,直接进入
|
||||||
next()
|
next()
|
||||||
}else{
|
}else{
|
||||||
if(getToken()){
|
if(getToken()){
|
||||||
if(to.path === '/login'){
|
if(to.path === '/login'){
|
||||||
|
// 如果是外部用户,把配置的路由跳转到个人中心
|
||||||
|
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' })
|
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/index' })
|
||||||
|
}
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
} else {
|
} 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) {
|
if (!store.getters.init) {
|
||||||
sessionStorage.removeItem(xpage.constants.localCaseFiltersKey);
|
sessionStorage.removeItem(xpage.constants.localCaseFiltersKey);
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ const user = {
|
|||||||
sessionStorage.setItem("curIdentity", iden);
|
sessionStorage.setItem("curIdentity", iden);
|
||||||
},
|
},
|
||||||
SET_UserInfo: (state, uinfo) => {
|
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
|
state.info = uinfo
|
||||||
},
|
},
|
||||||
SET_PERMISSIONS: (state, permissions) => {
|
SET_PERMISSIONS: (state, permissions) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user