修改代码

This commit is contained in:
ival 2019-11-15 16:29:11 +08:00
parent f9129558a6
commit a60b41398b
9 changed files with 129 additions and 142 deletions

View File

@ -64,7 +64,7 @@ class Jlmap {
loadStyle(lineCode) { loadStyle(lineCode) {
return selectLineCode(lineCode); return selectLineCode(lineCode);
}ine }
loadDefaultState() { loadDefaultState() {
const defaultStateDict = {}; const defaultStateDict = {};
@ -186,8 +186,8 @@ class Jlmap {
} }
for (var prop in elem) { for (var prop in elem) {
if (elem[prop] != oDevice[prop]) { if (oDevice[prop] != elem[prop]) {
deepAssign(oDevice, elem); oDevice[prop] = elem[prop];
return true; return true;
} }
} }

View File

@ -1,121 +1,117 @@
import store from '@/store'; import store from '@/store';
const exam = { const exam = {
namespaced: true, namespaced: true,
state: { state: {
started: false, // 考试状态 started: false, // 考试状态
usedTime: 0, // 考试当前所用时间 usedTime: 0, // 考试当前所用时间
totalTime: 0, // 考试总时间 totalTime: 0, // 考试总时间
timeInterval: null, // 计时器 timeInterval: null, // 计时器
suspend: false, // 暂停 suspend: false, // 暂停
ruleList: [], // 考试规则列表 ruleList: [], // 考试规则列表
courseDetail: {}, // 课程详情 courseDetail: {}, // 课程详情
courseList: [] // 课程列表 courseList: [] // 课程列表
}, },
getters: { getters: {
started: (state) => { started: (state) => {
return state.started; return state.started;
}, },
usedTime: (state) => { usedTime: (state) => {
return state.usedTime; return state.usedTime;
}, },
totalTime: (state) => { totalTime: (state) => {
return state.totalTime; return state.totalTime;
}, },
suspend: (state) => { suspend: (state) => {
return state.suspend; return state.suspend;
} }
}, },
mutations: { mutations: {
setStarted: (state, started) => { setStarted: (state, started) => {
state.started = started; state.started = started;
}, },
setSuspend: (state, suspend) => { setSuspend: (state, suspend) => {
state.suspend = suspend; state.suspend = suspend;
}, },
setUsedTime: (state, usedTime) => { setUsedTime: (state, usedTime) => {
state.usedTime = usedTime; state.usedTime = usedTime;
}, },
setTotalTime: (state, totalTime) => { setTotalTime: (state, totalTime) => {
state.totalTime = totalTime; state.totalTime = totalTime;
}, },
countUsedTime: (state) => { countUsedTime: (state) => {
if (state.timeInterval) { if (state.timeInterval) {
clearInterval(state.timeInterval); clearInterval(state.timeInterval);
state.timeInterval = null; state.timeInterval = null;
} }
state.timeInterval = setInterval(() => { state.timeInterval = setInterval(() => {
if (!state.suspend) { if (!state.suspend) {
state.usedTime++; state.usedTime++;
} }
}, 1000); }, 1000);
}, },
stopCountTime: (state) => { stopCountTime: (state) => {
if (state.timeInterval) { if (state.timeInterval) {
clearInterval(state.timeInterval); clearInterval(state.timeInterval);
state.timeInterval = null; state.timeInterval = null;
} }
}, },
setRuleList: (state, ruleList) => { setRuleList: (state, ruleList) => {
state.ruleList = ruleList; state.ruleList = ruleList;
}, },
setCourseDetail: (state, courseDetail) => { setCourseDetail: (state, courseDetail) => {
state.courseDetail = courseDetail; state.courseDetail = courseDetail;
}, },
setCourse: (state, courseList) => { setCourse: (state, courseList) => {
state.courseList = courseList; state.courseList = courseList;
} }
}, },
actions: { actions: {
start({ commit }) { start({ commit }) {
commit('setStarted', true); commit('setStarted', true);
commit('setSuspend', false); commit('setSuspend', false);
commit('setUsedTime', 0); commit('setUsedTime', 0);
commit('countUsedTime'); commit('countUsedTime');
}, },
over({ commit }) { over({ commit }) {
commit('setStarted', false); commit('setStarted', false);
commit('setSuspend', true); commit('setSuspend', true);
commit('setUsedTime', 0); commit('setUsedTime', 0);
commit('stopCountTime'); commit('stopCountTime');
}, },
isOver() { isOver() {
const trainingList = store.getters['trainingList/trainingList']; const trainingList = store.getters['trainingList/trainingList'];
const doList = trainingList.filter(elem => { const doList = trainingList.filter(elem => {
if (elem.usedTime !== undefined) return true; if (elem.usedTime !== undefined) return true;
}); });
if (doList.length >= trainingList.length) { if (doList.length >= trainingList.length) {
return true; return true;
} }
}, },
setSuspend({ commit }, suspend) { setSuspend({ commit }, suspend) {
commit('setSuspend', suspend); commit('setSuspend', suspend);
}, },
setUsedTime({ state }, usedTime) { setUsedTime({ commit }, usedTime) {
if (usedTime) { commit('setUsedTime', usedTime || 0);
state.usedTime = usedTime; },
} setTotalTime({ commit }, totalTime) {
}, commit('setTotalTime', totalTime || 0);
setTotalTime({ commit }, totalTime) { },
if (totalTime) { countUsedTime({ commit }) {
commit('setTotalTime', totalTime); commit('countUsedTime');
} },
}, setRuleList({ commit }, ruleList) {
countUsedTime({ commit }) { commit('setRuleList', ruleList);
commit('countUsedTime'); },
}, setCourseDetail({ commit }, courseDetail) {
setRuleList({ commit }, ruleList) { commit('setCourseDetail', courseDetail);
commit('setRuleList', ruleList); },
}, setCourse({ commit }, course) {
setCourseDetail({ commit }, courseDetail) { commit('setCourse', course);
commit('setCourseDetail', courseDetail); }
}, }
setCourse({ commit }, course) {
commit('setCourse', course);
}
}
}; };
export default exam; export default exam;

View File

@ -531,6 +531,7 @@ const map = {
state.map = map; state.map = map;
state.mapDevice = parser(map, map.skinVO.code); state.mapDevice = parser(map, map.skinVO.code);
} else { } else {
state.map = null;
state.mapDevice = {}; state.mapDevice = {};
} }
}, },

View File

@ -2,8 +2,8 @@
export function getBaseUrl() { export function getBaseUrl() {
let BASE_API; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud'; BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪 // BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.41:9000'; // 杜闪 // BASE_API = 'http://192.168.3.41:9000'; // 杜闪

View File

@ -1,5 +1,6 @@
import axios from 'axios'; import axios from 'axios';
import store from '../store'; import store from '../store';
import { i18n } from '@/main.js';
import { MessageBox } from 'element-ui'; import { MessageBox } from 'element-ui';
import { getToken } from '@/utils/auth'; import { getToken } from '@/utils/auth';
import { getBaseUrl } from '@/utils/baseUrl'; import { getBaseUrl } from '@/utils/baseUrl';
@ -42,8 +43,8 @@ service.interceptors.response.use(
EventBus.$emit('viewLoading', false); EventBus.$emit('viewLoading', false);
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
EventBus.$emit('clearCheckLogin'); EventBus.$emit('clearCheckLogin');
MessageBox.confirm(this.$t('tip.logoutTips'), this.$t('tip.hint'), { MessageBox.confirm(i18n.t('tip.logoutTips'), i18n.t('tip.hint'), {
confirmButtonText: this.$t('tip.confirmLogin'), confirmButtonText: i18n.t('tip.confirmLogin'),
showCancelButton: false, showCancelButton: false,
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {

View File

@ -2,24 +2,23 @@ import Vue from 'vue';
import StompClient from '@/utils/sock'; import StompClient from '@/utils/sock';
import store from '@/store'; import store from '@/store';
export const displayTopic = '/user/queue/simulation'; // 其他仿真topic export const displayTopic = '/user/queue/simulation/design'; // 其他仿真topic
export const planTopic = '/user/queue/simulation/plan'; // 测试运行仿真
export const designDisplayTopic = '/user/queue/simulation/design'; // 设计平台仿真订阅路径
export const perpetualTopic = '/user/topic/message'; // 公用topic export const perpetualTopic = '/user/topic/message'; // 公用topic
export const commonTopic = '/topic/message'; // 公共topic(不区分用户) export const commonTopic = '/topic/message'; // 公共topic(不区分用户)
// 建立连接并订阅地址 // 建立连接并订阅地址
export function creatSubscribe(topic, header) { export function creatSubscribe(topic, header) {
// if ([displayTopic, planTopic, designDisplayTopic].includes(topic)) {
// topic = `${topic}/${header.group}`;
// }
try { try {
if (!Vue.prototype.$stomp) { if (!Vue.prototype.$stomp) {
Vue.prototype.$stomp = new StompClient(); Vue.prototype.$stomp = new StompClient();
} }
Vue.prototype.$stomp.subscribe(topic, callback, header); Vue.prototype.$stomp.subscribe(
// [displayTopic].includes(topic) ? `${topic}/${header.group}` : topic,
topic,
callback,
header
);
} catch (error) { } catch (error) {
console.error('websocket订阅失败'); console.error('websocket订阅失败');
} }

View File

@ -20,7 +20,6 @@
import TipExamList from './tipExamList'; import TipExamList from './tipExamList';
import { Notification } from 'element-ui'; import { Notification } from 'element-ui';
import { startTraining } from '@/api/jmap/training'; import { startTraining } from '@/api/jmap/training';
import { exitFullscreen } from '@/utils/screen';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import { refreshExamList, finishOneExamQuestion } from '@/api/management/userexam'; import { refreshExamList, finishOneExamQuestion } from '@/api/management/userexam';
import { launchFullscreen } from '@/utils/screen'; import { launchFullscreen } from '@/utils/screen';

View File

@ -180,6 +180,7 @@ export default {
trainingId: '', trainingId: '',
id: '' id: ''
}; };
if (this.$route.query.examQuestionId && this.$route.query.trainingId) { if (this.$route.query.examQuestionId && this.$route.query.trainingId) {
obj.trainingId = this.$route.query.trainingId; obj.trainingId = this.$route.query.trainingId;
obj.id = this.$route.query.examQuestionId; obj.id = this.$route.query.examQuestionId;
@ -260,7 +261,6 @@ export default {
}); });
}, },
submit() { submit() {
// exitFullscreen();
this.$store.dispatch('exam/over').then(() => { this.$store.dispatch('exam/over').then(() => {
this.$store.dispatch('trainingList/clearTrainingList'); this.$store.dispatch('trainingList/clearTrainingList');
this.$router.replace({ path: `/trainingPlatform/result/${this.$route.query.userExamId}`, query: {subSystem: this.$route.query.subSystem} }); this.$router.replace({ path: `/trainingPlatform/result/${this.$route.query.userExamId}`, query: {subSystem: this.$route.query.subSystem} });

View File

@ -7,7 +7,7 @@
<script> <script>
import MapCommon from './common/index'; import MapCommon from './common/index';
import { getToken } from '@/utils/auth'; import { getToken } from '@/utils/auth';
import { creatSubscribe, clearSubscribe, displayTopic, planTopic, designDisplayTopic} from '@/utils/stomp'; import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp';
import { sendCommand } from '@/api/jmap/training'; import { sendCommand } from '@/api/jmap/training';
import { getSessionStorage } from '@/utils/auth'; import { getSessionStorage } from '@/utils/auth';
@ -105,21 +105,12 @@ export default {
async subscribe() { async subscribe() {
this.clearSubscribe(); this.clearSubscribe();
const header = { group: this.group || '', 'X-Token': getToken() }; const header = { group: this.group || '', 'X-Token': getToken() };
creatSubscribe(displayTopic, header);
if (this.mode === 'plan') {
creatSubscribe(planTopic, header);
} else {
creatSubscribe(this.isDesignPlatform ? designDisplayTopic : displayTopic, header);
}
await this.$store.dispatch('training/setHasSubscribed'); await this.$store.dispatch('training/setHasSubscribed');
}, },
clearSubscribe() { clearSubscribe() {
if (this.mode === 'plan') { clearSubscribe(displayTopic);
clearSubscribe(planTopic);
} else {
clearSubscribe(this.isDesignPlatform ? designDisplayTopic : displayTopic);
}
}, },
sendDeviceChangeEvent(data, header) { sendDeviceChangeEvent(data, header) {
// //