This commit is contained in:
joylink_cuiweidong 2019-11-14 17:03:54 +08:00
commit 52c4d0e08d
7 changed files with 52 additions and 51 deletions

View File

@ -126,7 +126,7 @@
</el-table-column> </el-table-column>
</template> </template>
</el-table> </el-table>
<div v-if="!queryList.selectCheckShow" style="margin-top: 8px; margin-left: 8px;"> <div v-if="queryList.selectCheckShow" style="margin-top: 8px; margin-left: 8px;">
<el-button <el-button
size="mini" size="mini"
:type="'primary'" :type="'primary'"

View File

@ -16,6 +16,14 @@ function hasPermission(roles, permissionRoles) {
const whiteList = ['/login', '/design/login', '/xty/login', '/designxty/login']; // 不重定向白名单 const whiteList = ['/login', '/design/login', '/xty/login', '/designxty/login']; // 不重定向白名单
const designPageRegex = [/^\/design/, /^\/scriptDisplay/, /^\/publish/, /^\/orderauthor/, /^\/system/, /^\/display\/record/, /^\/display\/manage/, /^\/apply/, /^\/plan/, /^\/display\/plan/];
function isDesignPage(toRoutePath) {
return designPageRegex.some(item => {
return item.test(toRoutePath);
});
}
const loginPage = whiteList[0]; const loginPage = whiteList[0];
const loginDesignPage = whiteList[1]; const loginDesignPage = whiteList[1];
@ -32,17 +40,9 @@ function getRouteInfo(to) {
if (/^\/designxty/.test(toRoutePath)) { if (/^\/designxty/.test(toRoutePath)) {
loginPath = loginDesignXtyPage; loginPath = loginDesignXtyPage;
clientId = LoginParams.Design.clientId; clientId = LoginParams.Design.clientId;
} else if (/^\/design/.test(toRoutePath) || /^\/scriptDisplay/.test(toRoutePath) || /^\/publish/.test(toRoutePath) || /^\/orderauthor/.test(toRoutePath) || /^\/system/.test(toRoutePath) || /^\/display\/record/.test(toRoutePath) || /^\/display\/manage/.test(toRoutePath) || /^\/apply/.test(toRoutePath)) { } else if (isDesignPage(toRoutePath)) {
loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage; loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage;
clientId = LoginParams.Design.clientId; clientId = LoginParams.Design.clientId;
} else if (/^\/plan/.test(toRoutePath) || /^\/display\/plan/.test(toRoutePath)) {
if (getSessionStorage('project').startsWith('design')) {
loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage;
clientId = LoginParams.Design.clientId;
} else {
loginPath = getSessionStorage('project') === 'xty' ? loginXtyPage : loginPage;
clientId = null;
}
} else if ( /^\/xty/.test(toRoutePath)) { } else if ( /^\/xty/.test(toRoutePath)) {
loginPath = loginXtyPage; loginPath = loginXtyPage;
clientId = null; clientId = null;

View File

@ -134,7 +134,7 @@ export const userLesson = '012'; // 教学系统
export const userSimulation = '013'; // 仿真系统 export const userSimulation = '013'; // 仿真系统
export const userScreen = '014'; // 大屏系统 export const userScreen = '014'; // 大屏系统
export const userPlan = '015'; // 计划系统 export const userPlan = '015'; // 计划系统
export const userDesign = '016'; // 设计系统 export const userTrainingPlatform = '016'; // 实训平台
// const isDev = process.env.NODE_ENV === 'development'; // const isDev = process.env.NODE_ENV === 'development';
export const UrlConfig = { export const UrlConfig = {
@ -288,7 +288,7 @@ export const asyncRouter = [
component: Layout, component: Layout,
redirect: '/design/home', redirect: '/design/home',
meta: { meta: {
roles: [admin, user, userDesign] roles: [admin, user]
}, },
children: [ children: [
{ {
@ -376,7 +376,7 @@ export const asyncRouter = [
redirect: '/design/userlist/home', redirect: '/design/userlist/home',
component: Layout, component: Layout,
meta: { meta: {
roles: [admin, user, userDesign] roles: [admin, user]
}, },
children: [ children: [
{ {
@ -453,7 +453,7 @@ export const asyncRouter = [
component: Layout, component: Layout,
hidden: true, hidden: true,
meta: { meta: {
roles: [admin, userSimulation, user] roles: [admin, userSimulation, user, userTrainingPlatform]
}, },
children: [ children: [
{ {
@ -550,7 +550,7 @@ export const asyncRouter = [
component: Layout, component: Layout,
meta: { meta: {
i18n: 'router.pulishManage', i18n: 'router.pulishManage',
roles: [admin, userDesign] roles: [admin]
}, },
children: [ children: [
{ // 发布地图 { // 发布地图
@ -629,7 +629,7 @@ export const asyncRouter = [
component: Layout, component: Layout,
meta: { meta: {
i18n: 'router.orderAuthorityManage', i18n: 'router.orderAuthorityManage',
roles: [admin, userDesign] roles: [admin]
}, },
children: [ children: [
{ {
@ -721,7 +721,7 @@ export const asyncRouter = [
component: Layout, component: Layout,
meta: { meta: {
i18n: 'router.systemManage', i18n: 'router.systemManage',
roles: [admin, userDesign] roles: [admin]
}, },
children: [ children: [
{ {
@ -820,7 +820,7 @@ export const asyncRouter = [
component: Layout, component: Layout,
meta: { meta: {
i18n: 'router.releaseApplication', i18n: 'router.releaseApplication',
roles: [admin, userDesign] roles: [admin]
}, },
children: [ children: [
{ {

View File

@ -1,4 +1,4 @@
import { asyncRouter, constantRoutes, user, userLesson, userExam, userSimulation, userScreen, userPlan, superAdmin, admin, userDesign } from '@/router'; import { asyncRouter, constantRoutes, user, userLesson, userExam, userSimulation, userScreen, userPlan, superAdmin, admin, userTrainingPlatform } from '@/router';
import { PermissionType } from '@/utils/PermissionType'; import { PermissionType } from '@/utils/PermissionType';
import { UrlConfig } from '@/router/index'; import { UrlConfig } from '@/router/index';
import { getSessionStorage } from '@/utils/auth'; import { getSessionStorage } from '@/utils/auth';
@ -36,7 +36,7 @@ function hasPermission(roles, route, parentsRoles) {
roles = roles.filter(function (role) { roles = roles.filter(function (role) {
return route.meta.roles.indexOf(role) >= 0; return route.meta.roles.indexOf(role) >= 0;
}); });
return roles.some(role => route.meta.roles.indexOf(role) >= 0) && route.meta.roles.indexOf(userDesign) < 0; return roles.some(role => route.meta.roles.indexOf(role) >= 0) && route.meta.roles.indexOf(userTrainingPlatform) > 0;
} }
} else if (parentsRoles) { } else if (parentsRoles) {
// 如果没有本级路由,有父级路由,则使用父级路由过滤 // 如果没有本级路由,有父级路由,则使用父级路由过滤

View File

@ -2,8 +2,8 @@ const trainingList = {
namespaced: true, namespaced: true,
state: { state: {
index: 0, //当前选择实训索引 index: 0, // 当前选择实训索引
trainingList: [], //实训初始列表 trainingList: [] // 实训初始列表
}, },
getters: { getters: {
trainingList: (state) => { trainingList: (state) => {
@ -36,7 +36,7 @@ const trainingList = {
} else { } else {
state.trainingList = []; state.trainingList = [];
} }
}, }
}, },
actions: { actions: {
setIndex({ commit }, index) { setIndex({ commit }, index) {

View File

@ -53,6 +53,18 @@ const user = {
Cookies.remove('UserDesignToken'); Cookies.remove('UserDesignToken');
Cookies.remove('UserName'); Cookies.remove('UserName');
Cookies.remove('UserToken'); Cookies.remove('UserToken');
},
SUBSCRIBE: (state, {header, type}) => {
if (type == 'design') {
creatSubscribe(commonTopic, header);
} else {
creatSubscribe(perpetualTopic, header);
creatSubscribe(commonTopic, header);
}
},
SUBSCRIBE_UN: () => {
clearSubscribe(perpetualTopic);
clearSubscribe(commonTopic);
} }
}, },
@ -61,41 +73,32 @@ const user = {
Login({ commit }, userInfo) { Login({ commit }, userInfo) {
const username = userInfo.username.trim(); const username = userInfo.username.trim();
const password = userInfo.password.trim(); const password = userInfo.password.trim();
const type = userInfo.type;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let params = null;
let execFunc = null;
if (userInfo.type == 'design') {
params = Object.assign({ account: username, password }, LoginParams.Design);
execFunc = (header) => {
creatSubscribe(commonTopic, header);
};
} else {
params = Object.assign({ account: username, password }, LoginParams.LianKeTang);
execFunc = (header) => {
creatSubscribe(perpetualTopic, header);
creatSubscribe(commonTopic, header);
};
}
// 登录系统 // 登录系统
const params = Object.assign({ account: username, password }, type == 'design' ? LoginParams.Design : LoginParams.LianKeTang);
login(params).then(resp => { login(params).then(resp => {
const token = resp.data; const token = resp.data;
commit('SET_TOKEN', token); const header = { group: '', 'X-Token': token };
setToken(token); setToken(token);
execFunc({ group: '', 'X-Token': token }); commit('SET_TOKEN', token);
commit('SUBSCRIBE', {header, type});
resolve(); resolve();
}).catch(error => { reject(error); }); }).catch(error => { reject(error); });
}); });
}, },
// 扫码登陆设置 // 扫码登陆设置
QrLoginSetting({ dispatch, commit }, token) { QrLoginSetting({ dispatch, commit }, tokeninfo) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 设置user域token值 // 设置user域token值
commit(token.key, token.value); const header = { group: '', 'X-Token': tokeninfo.value };
const header = { group: '', 'X-Token': token.value }; const mutAction = tokeninfo.key;
creatSubscribe(perpetualTopic, header); const mutParams = tokeninfo.value;
creatSubscribe(commonTopic, header); const type = tokeninfo.type;
setToken(tokeninfo.value);
commit(mutAction, mutParams);
commit('SUBSCRIBE', {header, type});
// 获取用户参数 // 获取用户参数
dispatch('GetUserConfigInfo').then(response => { dispatch('GetUserConfigInfo').then(response => {
resolve(response); resolve(response);
@ -140,8 +143,7 @@ const user = {
}, },
// 前端登出 // 前端登出
FedLogOut({ commit }) { FedLogOut({ commit }) {
clearSubscribe(perpetualTopic); commit('SUBSCRIBE_UN');
clearSubscribe(commonTopic);
commit('SET_TOKEN', ''); commit('SET_TOKEN', '');
commit('SET_ID', ''); commit('SET_ID', '');
removeToken(); removeToken();

View File

@ -100,7 +100,6 @@ import QrcodeVue from 'qrcode.vue';
import { getLoginWmurl, checkLoginStatus } from '@/api/login'; import { getLoginWmurl, checkLoginStatus } from '@/api/login';
import { LoginParams } from '@/utils/login'; import { LoginParams } from '@/utils/login';
import bgImg from '@/assets/bg1.jpg'; import bgImg from '@/assets/bg1.jpg';
import { setToken } from '@/utils/auth';
import { loginInfo } from '@/scripts/ConstDic'; import { loginInfo } from '@/scripts/ConstDic';
import { removeToken } from '@/utils/auth'; import { removeToken } from '@/utils/auth';
import LangStorage from '@/utils/lang'; import LangStorage from '@/utils/lang';
@ -238,14 +237,14 @@ export default {
if (this && this._isDestroyed) { if (this && this._isDestroyed) {
return; return;
} }
// //
// //
this.clearTimer(this.checkLogin); this.clearTimer(this.checkLogin);
this.checkLogin = setTimeout(() => { this.checkLogin = setTimeout(() => {
checkLoginStatus(self.sessionId).then(response => { checkLoginStatus(self.sessionId).then(response => {
setToken(response.data.token);
// //
self.$store.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token }).then(() => { self.$store.dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token, type: this.modelType }).then(() => {
// //
self.clearTimer(self.checkLogin); self.clearTimer(self.checkLogin);
this.handleLoginSucessRoute(); this.handleLoginSucessRoute();