修改代码

This commit is contained in:
ival 2019-11-14 16:45:31 +08:00
parent 6d23cedbf4
commit c362d64048
3 changed files with 31 additions and 39 deletions

View File

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

View File

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

View File

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