2019-07-02 16:29:52 +08:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
|
|
|
<router-view />
|
2019-09-02 10:38:10 +08:00
|
|
|
<deomon-topic ref="deomonTopic" />
|
2020-09-11 15:52:15 +08:00
|
|
|
<img v-show="loading" :src="loadingImg" style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;z-index: 2003">
|
2019-07-02 16:29:52 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-11-14 13:59:33 +08:00
|
|
|
import { getToken } from '@/utils/auth';
|
|
|
|
import { getSessionStorage } from '@/utils/auth';
|
2020-04-16 13:47:40 +08:00
|
|
|
import { loginInfo, ProjectIcon } from '@/scripts/ProjectConfig';
|
2019-08-14 16:15:44 +08:00
|
|
|
import DeomonTopic from '@/views/demonstration/deomonTopic';
|
2019-09-02 10:38:10 +08:00
|
|
|
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
2020-09-01 15:07:47 +08:00
|
|
|
import LoadingImg from '@/assets/loading.gif';
|
2019-09-02 10:38:10 +08:00
|
|
|
|
2019-07-02 16:29:52 +08:00
|
|
|
export default {
|
2019-11-05 16:40:36 +08:00
|
|
|
name: 'App',
|
|
|
|
components: {
|
|
|
|
DeomonTopic
|
|
|
|
},
|
|
|
|
mixins: [
|
|
|
|
WindowResizeHandler
|
|
|
|
],
|
2020-09-01 15:07:47 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loadingImg: LoadingImg,
|
2020-09-09 10:28:56 +08:00
|
|
|
loading: false
|
2020-09-01 15:07:47 +08:00
|
|
|
};
|
|
|
|
},
|
2019-11-05 16:40:36 +08:00
|
|
|
watch: {
|
2020-06-30 18:35:57 +08:00
|
|
|
'$store.state.socket.simulationInvite': function (val) {
|
|
|
|
if (val.creator) {
|
2019-11-05 16:40:36 +08:00
|
|
|
this.subscribeMessage(val);
|
|
|
|
}
|
2019-11-14 13:59:33 +08:00
|
|
|
},
|
2020-07-13 14:34:56 +08:00
|
|
|
'$store.state.socket.roomInvite': function (val) {
|
|
|
|
if (val.creator) {
|
|
|
|
this.subscribeMessage(val);
|
|
|
|
}
|
|
|
|
},
|
2019-11-18 10:34:18 +08:00
|
|
|
'$store.state.socket.beLogoutCount': async function(val) {
|
2020-01-14 18:18:54 +08:00
|
|
|
this.$store.dispatch('disconnect').then(()=>{
|
|
|
|
this.$alert(this.$t('tip.logoutTips'), this.$t('tip.hint'), {
|
|
|
|
confirmButtonText: this.$t('tip.confirm'),
|
|
|
|
callback: action => {
|
|
|
|
this.$store.dispatch('exit').then(resp => {
|
|
|
|
this.$router.push({path: loginInfo[getSessionStorage('project')].loginPath});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2019-11-14 13:59:33 +08:00
|
|
|
});
|
2020-09-01 15:07:47 +08:00
|
|
|
},
|
|
|
|
'$store.state.app.transitionAnimationsCount': function(val) {
|
2020-09-09 10:28:56 +08:00
|
|
|
this.loading = true;
|
2020-09-01 15:07:47 +08:00
|
|
|
},
|
2020-09-09 10:28:56 +08:00
|
|
|
'$store.state.app.animationsCloseCount': function(val) {
|
|
|
|
this.loading = false;
|
2019-11-05 16:40:36 +08:00
|
|
|
}
|
|
|
|
},
|
2020-04-16 13:47:40 +08:00
|
|
|
created() {
|
|
|
|
const project = getSessionStorage('project');
|
|
|
|
if (project) {
|
2020-06-15 14:26:31 +08:00
|
|
|
document.querySelector("link[rel*='icon']").href = loginInfo[project].linkIcon || ProjectIcon[project];
|
2020-04-16 13:47:40 +08:00
|
|
|
}
|
|
|
|
},
|
2019-11-05 16:40:36 +08:00
|
|
|
mounted() {
|
|
|
|
this.prohibitSystemContextMenu();
|
2019-11-12 13:44:10 +08:00
|
|
|
|
|
|
|
window.addEventListener('beforeunload', async e => {
|
2020-07-22 14:19:58 +08:00
|
|
|
if (!this.$route.query.noPreLogout) {
|
|
|
|
await this.$store.dispatch('preLogout');
|
|
|
|
}
|
2019-11-12 13:44:10 +08:00
|
|
|
});
|
2019-11-12 17:27:30 +08:00
|
|
|
|
2019-11-19 10:54:52 +08:00
|
|
|
this.$nextTick(() => { this.subscribe(); });
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
resizeHandler() {
|
2020-07-27 18:04:47 +08:00
|
|
|
this.$store.dispatch('app/resize', { width: this._clientWidth, height: this._clientHeight });
|
2019-11-05 16:40:36 +08:00
|
|
|
},
|
|
|
|
prohibitSystemContextMenu() {
|
|
|
|
window.document.oncontextmenu = function () {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
},
|
2019-11-12 17:27:30 +08:00
|
|
|
subscribeMessage(res) {
|
2019-12-10 15:06:29 +08:00
|
|
|
if (this.$refs.deomonTopic && !window.location.href.includes('trainroom')) {
|
2020-11-23 17:32:17 +08:00
|
|
|
if (!(getSessionStorage('project').includes('design'))) {
|
2020-05-21 16:59:36 +08:00
|
|
|
this.$refs.deomonTopic.doShow(res);
|
|
|
|
}
|
2020-06-30 18:35:57 +08:00
|
|
|
this.$store.dispatch('socket/setSimulationInvite');
|
2020-07-13 14:34:56 +08:00
|
|
|
this.$store.dispatch('socket/setRoomInvite');
|
2019-11-12 17:27:30 +08:00
|
|
|
}
|
|
|
|
},
|
2019-11-05 16:40:36 +08:00
|
|
|
subscribe() {
|
2019-11-19 10:54:52 +08:00
|
|
|
const token = getToken();
|
2020-11-25 13:31:36 +08:00
|
|
|
const path = window.location.pathname;
|
|
|
|
if (token && this.$route.path != '/404' && !path.endsWith('login')) {
|
2019-11-19 10:54:52 +08:00
|
|
|
const header = { group: '', 'X-Token': token };
|
|
|
|
this.$store.dispatch('subscribe', {header, type: getSessionStorage('project')});
|
|
|
|
}
|
2019-11-05 16:40:36 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-08 11:29:03 +08:00
|
|
|
};
|
|
|
|
|
2019-07-02 16:29:52 +08:00
|
|
|
</script>
|