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