rt-sim-training-client/src/App.vue

74 lines
2.2 KiB
Vue
Raw Normal View History

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" />
2019-07-02 16:29:52 +08:00
</div>
</template>
<script>
import { handleToken } from '@/utils/auth';
2019-11-05 16:40:36 +08:00
import { creatSubscribe, perpetualTopic, commonTopic } from '@/utils/stomp';
import DeomonTopic from '@/views/demonstration/deomonTopic';
2019-09-02 10:38:10 +08:00
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
2019-11-11 17:03:21 +08:00
import Cookies from 'js-cookie';
import { ProjectIcon } from '@/scripts/ConstDic';
2019-11-11 17:03:21 +08:00
import { logout } from '@/api/login';
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
],
watch: {
'$store.state.socket.roomInvite': function (val) {
if (val.creatorId) {
this.subscribeMessage(val);
}
}
},
mounted() {
this.prohibitSystemContextMenu();
this.subscribe();
const project = window.sessionStorage.getItem('project');
document.querySelector("link[rel*='icon']").href = ProjectIcon[project];
2019-11-11 20:04:31 +08:00
// window.addEventListener('beforeunload', async e => {
// const token = handleToken();
// Cookies.remove('UserDesignName');
// Cookies.remove('UserDesignToken');
// Cookies.remove('UserName');
// Cookies.remove('UserToken');
// await logout(token);
// });
2019-11-05 16:40:36 +08:00
},
methods: {
resizeHandler() {
this.$store.dispatch('app/resize', {width: this._clientWidth, height: this._clientHeight});
},
prohibitSystemContextMenu() {
window.document.oncontextmenu = function () {
return false;
};
},
subscribe() {
this.$nextTick(() => {
if (!this.$route.path.includes('/login') && this.$route.path != '/404') {
const header = { group: '', 'X-Token': handleToken() };
creatSubscribe(perpetualTopic, header);
creatSubscribe(commonTopic, header);
}
});
},
subscribeMessage(res) {
if (this.$refs.deomonTopic) {
this.$refs.deomonTopic.doShow(res);
this.$store.dispatch('socket/setRoomInvite');
}
}
}
2019-08-08 11:29:03 +08:00
};
2019-07-02 16:29:52 +08:00
</script>