parent
0c45e5dd8a
commit
a91e5f20ad
14 changed files with 145 additions and 126 deletions
@ -1,30 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="breadcrumb"> |
|
||||||
<span class="cur">当前位置:</span> |
|
||||||
<el-breadcrumb separator="/"> |
|
||||||
<el-breadcrumb-item :to="{ path: '/' }">超竞学生端</el-breadcrumb-item> |
|
||||||
<el-breadcrumb-item v-for="(item,index) in pages" :key="index" :to="{ path: index == pages.length - 1 ? curRoute : path }">{{item}}</el-breadcrumb-item> |
|
||||||
</el-breadcrumb> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
|
|
||||||
<script> |
|
||||||
export default { |
|
||||||
props: ['data','route'], |
|
||||||
data() { |
|
||||||
return { |
|
||||||
pages: this.data.split('/'), |
|
||||||
curRoute: this.$route.path, |
|
||||||
path: this.route ? this.route : 'list' |
|
||||||
}; |
|
||||||
}, |
|
||||||
methods: { |
|
||||||
update(data){ |
|
||||||
this.pages = data.split('/') |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
</script> |
|
||||||
<style lang="scss" scoped> |
|
||||||
|
|
||||||
</style> |
|
@ -1,27 +1,49 @@ |
|||||||
import router from './index' |
import router from './index' |
||||||
import Setting from '@/setting' |
import Setting from '@/setting' |
||||||
import util from '@/libs/util' |
import util from '@/libs/util' |
||||||
|
import store from '@/store' |
||||||
|
const managerPath = ['/stat/list','/user/list','/role/list'] // 管理员才能访问的页面路径
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => { |
router.beforeEach((to, from, next) => { |
||||||
document.title = Setting.titleSuffix |
document.title = Setting.titleSuffix |
||||||
const role = util.local.get(Setting.tokenKey) |
const role = util.local.get(Setting.tokenKey) |
||||||
if (!role && to.path !== '/login') { |
if (!role && to.path !== '/login' && to.path !== '/index/list') { |
||||||
next('/login') |
next('/login') |
||||||
} else if(role && to.path == '/login') { |
} else if(role && to.path == '/login') { |
||||||
next('/index') |
next('/index') |
||||||
} else { |
} else { |
||||||
let mg = from.query.mg |
let mg = from.query.mg |
||||||
if(mg){ |
let routes = store.state.auth.routes |
||||||
|
let toPath = to.path |
||||||
|
// mg是判断是否是管理员的参数,base64解码后如果等于true则为管理员,否则为普通用户。
|
||||||
|
// 如果是管理员则需要从获取的路由权限里判断当前访问页面是否有权限访问,如果没权限访问则跳转到403
|
||||||
|
if((mg && atob(decodeURI(mg)) === 'true') || (to.query.mg && atob(decodeURI(to.query.mg)) === 'true')){ |
||||||
|
if(routes.length){ |
||||||
|
if(routes.find(n => n.name == toPath) || toPath == '/setting/person'){ |
||||||
if(!to.query.mg){ |
if(!to.query.mg){ |
||||||
next({ |
next({ |
||||||
path: to.path, |
path: toPath, |
||||||
query: {mg} |
query: {mg} |
||||||
}) |
}) |
||||||
}else{ |
}else{ |
||||||
next() |
next() |
||||||
} |
} |
||||||
|
}else{ |
||||||
|
if(to.path != '/403'){ |
||||||
|
next('/403') |
||||||
|
}else{ |
||||||
|
next() |
||||||
|
} |
||||||
|
} |
||||||
}else{ |
}else{ |
||||||
next() |
next() |
||||||
} |
} |
||||||
|
}else{// 如果是普通用户,则无法访问上面定义的常量里的3个页面路径
|
||||||
|
if(managerPath.includes(toPath)){ |
||||||
|
next('/403') |
||||||
|
}else{ |
||||||
|
next() |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
}); |
}) |
@ -1,24 +0,0 @@ |
|||||||
/** |
|
||||||
* 通用 |
|
||||||
* */ |
|
||||||
|
|
||||||
const roleList = { |
|
||||||
'1': '超级管理员', |
|
||||||
'2': '管理员', |
|
||||||
'3': '老师', |
|
||||||
'4': '学生' |
|
||||||
} |
|
||||||
export default { |
|
||||||
namespaced: true, |
|
||||||
state: { |
|
||||||
|
|
||||||
}, |
|
||||||
mutations: { |
|
||||||
|
|
||||||
}, |
|
||||||
actions: { |
|
||||||
getRole (id) { |
|
||||||
return roleList[id] || '未知状态' |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue