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

60 lines
1.3 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';
import { creatSubscribe, perpetualTopic } from '@/utils/stomp';
import DeomonTopic from '@/views/demonstration/deomonTopic';
2019-09-02 10:38:10 +08:00
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
2019-07-02 16:29:52 +08:00
export default {
name: 'App',
components: {
DeomonTopic
},
2019-09-02 10:38:10 +08:00
mixins: [
WindowResizeHandler
],
watch: {
'$store.state.socket.roomInvite': function (val) {
if (val.creatorId) {
this.subscribeMessage(val);
}
}
},
mounted() {
this.prohibitSystemContextMenu();
this.subscribe();
},
methods: {
2019-09-02 10:38:10 +08:00
resizeHandler() {
this.$store.dispatch('app/resize', {width: this._clientWidth, height: this._clientHeight});
2019-09-02 10:38:10 +08:00
},
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);
}
});
},
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>