修改从CCTV界面点击菜单退出会直接退出登录问题

This commit is contained in:
dong 2022-12-30 14:15:13 +08:00
parent b97a155b24
commit bd0e1f1a9a

View File

@ -3,183 +3,183 @@ import { getToken } from '@/utils/auth';
import store from '@/store/index'; import store from '@/store/index';
// 定于仿真socket接口 // 定于仿真socket接口
export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passerStation,passerAi) { export function PassflowConnect(deviceaction, toptrain, downtrain, routegroup, passerStation, passerAi) {
const scope = this; const scope = this;
this.teststomp = new StompClient(); this.teststomp = new StompClient();
// let topic = '/user/queue/simulation/jl3d/'+routegroup; // let topic = '/user/queue/simulation/jl3d/'+routegroup;
let topic = '/user/queue/simulation/'+ routegroup +'/jl3d'; const topic = '/user/queue/simulation/' + routegroup + '/jl3d';
let header = {'X-Token': getToken() }; const header = {'X-Token': getToken() };
socketon(topic); socketon(topic);
function socketon(topic) { function socketon(topic) {
try { try {
scope.teststomp.subscribe(topic, callback, header); scope.teststomp.subscribe(topic, callback, header);
} catch (error) { } catch (error) {
console.error('websocket订阅失败'); console.error('websocket订阅失败');
} }
}; }
this.socketoff = function(topic) { this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic); scope.teststomp.unsubscribe(topic);
}; };
// 仿真socket接口回调函数 // 仿真socket接口回调函数
function callback(Response) { function callback(Response) {
const data = JSON.parse(Response.body); const data = JSON.parse(Response.body);
if(data.type == "DeviceCtrl_3D"){ if (data.type == 'DeviceCtrl_3D') {
if(data.body.type == "PSD"){ if (data.body.type == 'PSD') {
if(data.body.code == passerStation.nowStation.toppsd){ if (data.body.code == passerStation.nowStation.toppsd) {
if(data.body.command == 'G'){ if (data.body.command == 'G') {
deviceaction.top.action.reset(); deviceaction.top.action.reset();
deviceaction.top.action.time =deviceaction.top.action._clip.duration; deviceaction.top.action.time = deviceaction.top.action._clip.duration;
deviceaction.top.action.timeScale = -1; deviceaction.top.action.timeScale = -1;
deviceaction.top.action.play(); deviceaction.top.action.play();
}else{ } else {
passerAi.passerout("top") passerAi.passerout('top');
deviceaction.top.action.reset(); deviceaction.top.action.reset();
deviceaction.top.action.time = 0; deviceaction.top.action.time = 0;
deviceaction.top.action.timeScale = 1; deviceaction.top.action.timeScale = 1;
deviceaction.top.action.play(); deviceaction.top.action.play();
} }
} }
if(data.body.code == passerStation.nowStation.downpsd){ if (data.body.code == passerStation.nowStation.downpsd) {
if(data.body.command == 'G'){ if (data.body.command == 'G') {
deviceaction.down.action.reset(); deviceaction.down.action.reset();
deviceaction.down.action.time = deviceaction.down.action._clip.duration; deviceaction.down.action.time = deviceaction.down.action._clip.duration;
deviceaction.down.action.timeScale = -1; deviceaction.down.action.timeScale = -1;
deviceaction.down.action.play(); deviceaction.down.action.play();
}else{ } else {
passerAi.passerout("down"); passerAi.passerout('down');
deviceaction.down.action.reset(); deviceaction.down.action.reset();
deviceaction.down.action.time = 0; deviceaction.down.action.time = 0;
deviceaction.down.action.timeScale = 1; deviceaction.down.action.timeScale = 1;
deviceaction.down.action.play(); deviceaction.down.action.play();
} }
} }
} }
if(data.body.type == "TRAIN_DOOR"){ if (data.body.type == 'TRAIN_DOOR') {
if(toptrain.nowcode == data.body.trainCode){ if (toptrain.nowcode == data.body.trainCode) {
if(data.body.command == 'G'){ if (data.body.command == 'G') {
closetraindoor(toptrain,data.body.code,"top"); closetraindoor(toptrain, data.body.code, 'top');
}else{ } else {
opentraindoor(toptrain,data.body.code,"top"); opentraindoor(toptrain, data.body.code, 'top');
} }
} }
if(downtrain.nowcode == data.body.trainCode){ if (downtrain.nowcode == data.body.trainCode) {
// console.log(data.body); // console.log(data.body);
if(data.body.command == 'G'){ if (data.body.command == 'G') {
closetraindoor(downtrain,data.body.code,"down"); closetraindoor(downtrain, data.body.code, 'down');
}else{ } else {
opentraindoor(downtrain,data.body.code,"down"); opentraindoor(downtrain, data.body.code, 'down');
} }
} }
} }
} }
if(data.type == "TrainRun_3D"){ if (data.type == 'TrainRun_3D') {
for(let i=0,leni = data.body.length;i<leni;i++){ for (let i = 0, leni = data.body.length; i < leni; i++) {
if(data.body[i].section == passerStation.nowStation.topsection){ if (data.body[i].section == passerStation.nowStation.topsection) {
if(toptrain.nowcode != data.body[i].code){ if (toptrain.nowcode != data.body[i].code) {
toptrain.nowcode = data.body[i].code; toptrain.nowcode = data.body[i].code;
} }
toptrain.position.copy(passerStation.nowStation.topcurve.getPointAt(data.body[i].offset)); toptrain.position.copy(passerStation.nowStation.topcurve.getPointAt(data.body[i].offset));
// } // }
}else{ } else {
if(downtrain.nowcode == data.body[i].code){ if (downtrain.nowcode == data.body[i].code) {
toptrain.position.x -= 1; toptrain.position.x -= 1;
} }
} }
if(data.body[i].section == passerStation.nowStation.downsection){ if (data.body[i].section == passerStation.nowStation.downsection) {
if(downtrain.nowcode != data.body[i].code){ if (downtrain.nowcode != data.body[i].code) {
downtrain.nowcode = data.body[i].code; downtrain.nowcode = data.body[i].code;
} }
downtrain.position.copy(passerStation.nowStation.downcurve.getPointAt(data.body[i].offset)); downtrain.position.copy(passerStation.nowStation.downcurve.getPointAt(data.body[i].offset));
}else{ } else {
if(downtrain.nowcode == data.body[i].code){ if (downtrain.nowcode == data.body[i].code) {
downtrain.position.x += 1; downtrain.position.x += 1;
} }
} }
} }
} }
if(data.type == 'Simulation_Over') { // if(data.type == 'Simulation_Over') {
store.dispatch('LogOut').then(() => { // store.dispatch('LogOut').then(() => {
location.reload(); // location.reload();
}); // });
} // }
} }
let actions; let actions;
function opentraindoor(train,doorcode,direct){ function opentraindoor(train, doorcode, direct) {
if(direct == "top"){ if (direct == 'top') {
if(doorcode == "1"){ if (doorcode == '1') {
actions = train.action.down; actions = train.action.down;
} }
if(doorcode == "2"){ if (doorcode == '2') {
actions = train.action.top; actions = train.action.top;
} }
}else{ } else {
if(doorcode == "1"){ if (doorcode == '1') {
actions = train.action.top; actions = train.action.top;
} }
if(doorcode == "2"){ if (doorcode == '2') {
actions = train.action.down; actions = train.action.down;
} }
} }
for(let an=actions.length-1;an>=0;an--){ for (let an = actions.length - 1; an >= 0; an--) {
actions[an].reset(); actions[an].reset();
actions[an].time = 0; actions[an].time = 0;
actions[an].timeScale = 1; actions[an].timeScale = 1;
actions[an].play(); actions[an].play();
} }
} }
function closetraindoor(train,doorcode,direct){ function closetraindoor(train, doorcode, direct) {
if(direct == "top"){ if (direct == 'top') {
if(doorcode == "1"){ if (doorcode == '1') {
actions = train.action.down; actions = train.action.down;
} }
if(doorcode == "2"){ if (doorcode == '2') {
actions = train.action.top; actions = train.action.top;
} }
toptrain.nowcode = null; toptrain.nowcode = null;
}else{ } else {
if(doorcode == "1"){ if (doorcode == '1') {
actions = train.action.top; actions = train.action.top;
} }
if(doorcode == "2"){ if (doorcode == '2') {
actions = train.action.down; actions = train.action.down;
} }
downtrain.nowcode = null; downtrain.nowcode = null;
} }
for(let an=actions.length-1;an>=0;an--){ for (let an = actions.length - 1; an >= 0; an--) {
actions[an].reset(); actions[an].reset();
actions[an].time = actions[an]._clip.duration; actions[an].time = actions[an]._clip.duration;
actions[an].timeScale = -1; actions[an].timeScale = -1;
actions[an].play(); actions[an].play();
} }
} }
} }