mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 11:26:43 +08:00
前端白名单控制
This commit is contained in:
@@ -4,14 +4,12 @@ import ajax from '@/utils/xajax.js'
|
|||||||
/**
|
/**
|
||||||
* 查询白名单
|
* 查询白名单
|
||||||
* @param {
|
* @param {
|
||||||
* code:'',
|
* env:'开发环境'
|
||||||
* name:'',
|
|
||||||
* environment:0
|
|
||||||
* } data
|
* } data
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const getList = function(data) {
|
const getList =function(env) {
|
||||||
return ajax.post('/xboe/sys/whiteuser/list',data);
|
return ajax.post('/xboe/sys/whiteuser/codes',env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -410,10 +410,14 @@ export default {
|
|||||||
this.getLastStudy();
|
this.getLastStudy();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log(this.userInfo.loginName,'this.userInfo.loginName')
|
console.log(this.userInfo.loginName,'this.userInfo.loginName');
|
||||||
if(testUser.isTest(this.userInfo.loginName)){
|
let flag=testUser.isTest(this.userInfo.loginName);
|
||||||
this.isTest=true;
|
console.log(flag,'this.isTest22');
|
||||||
}
|
this.isTest=flag;
|
||||||
|
// if(testUser.isTest(this.userInfo.loginName)){
|
||||||
|
// console.log(this.isTest,'this.isTest');
|
||||||
|
// this.isTest=true;
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toCourseDetail(item){
|
toCourseDetail(item){
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'nprogress/nprogress.css'
|
|||||||
import { getToken } from '@/utils/token'
|
import { getToken } from '@/utils/token'
|
||||||
import { routers } from "@/data/pages"
|
import { routers } from "@/data/pages"
|
||||||
import watermark from './utils/warterMark.js'
|
import watermark from './utils/warterMark.js'
|
||||||
|
import testUser from './utils/testUsers.js'
|
||||||
import xpage from '@/utils/xpage'
|
import xpage from '@/utils/xpage'
|
||||||
|
|
||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
@@ -37,6 +38,8 @@ router.beforeEach((to, from, next) => {
|
|||||||
if (!store.getters.init) {
|
if (!store.getters.init) {
|
||||||
// 判断当前控制台是否已拉取完数据
|
// 判断当前控制台是否已拉取完数据
|
||||||
store.dispatch('InitData').then(res => {
|
store.dispatch('InitData').then(res => {
|
||||||
|
//加载白名单信息
|
||||||
|
testUser.init();
|
||||||
//加载信息资源归属,系统分类信息
|
//加载信息资源归属,系统分类信息
|
||||||
store.dispatch('resOwner/loadResOwners');
|
store.dispatch('resOwner/loadResOwners');
|
||||||
store.dispatch('sysType/loadSysTypes');
|
store.dispatch('sysType/loadSysTypes');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import apiWhiteuser from '@/api/system/whiteuser'
|
||||||
/**测试人员名单*/
|
/**测试人员名单*/
|
||||||
const userCodes=[
|
const userCodes=[
|
||||||
'12345601',
|
'12345601',
|
||||||
@@ -13,34 +14,36 @@ const userCodesPro=[
|
|||||||
'10181457'
|
'10181457'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const init=function(){
|
||||||
|
let data=sessionStorage.getItem('whiteuser-session');
|
||||||
|
if(!data){
|
||||||
|
apiWhiteuser.getList({}).then(rs=>{
|
||||||
|
if(rs.status==200){
|
||||||
|
if(rs.result && rs.result.length>0){
|
||||||
|
data = JSON.stringify(rs.result);
|
||||||
|
sessionStorage.setItem('whiteuser-session',data);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
console.log('获取白名单错误:'+rs.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**是否是测试人员*/
|
/**是否是测试人员*/
|
||||||
const isTest= function(code){
|
const isTest= function(code){
|
||||||
var testUser=false;
|
let data=sessionStorage.getItem('whiteuser-session');
|
||||||
var mode=process.env.NODE_ENV;
|
var flag=false;
|
||||||
|
if(data){
|
||||||
if(mode=='testing' || mode=='development'){
|
var codes=JSON.parse(data);
|
||||||
userCodes.some(item=>{
|
flag=codes.some(item=>{
|
||||||
if(item===code){
|
return (item==code);
|
||||||
testUser=true;
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
userCodesPro.some(item=>{
|
|
||||||
if(item===code){
|
|
||||||
testUser=true;
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
return flag;
|
||||||
return testUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
init,
|
||||||
isTest
|
isTest
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user