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

64 lines
1.8 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';
import { ProjectIcon } from '@/scripts/ConstDic';
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-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>