<template>
|
<div :class="classObj" class="app-wrapper">
|
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
|
<sidebar class="sidebar-container" />
|
<div class="main-container">
|
<div class="inner">
|
<div class="main-container-wrapper">
|
<div class="main-container-header">
|
<navbar />
|
<tags-view />
|
</div>
|
<div class="main-container-content">
|
<app-main />
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
|
import ResizeMixin from './mixin/ResizeHandler'
|
import { mapState } from 'vuex'
|
|
import createWs from '@/assets/js/websocket/plus';
|
const WSMixin = createWs('loginCheck');
|
|
export default {
|
name: 'Layout',
|
components: {
|
AppMain,
|
Navbar,
|
Settings,
|
Sidebar,
|
TagsView
|
},
|
mixins: [ResizeMixin, WSMixin],
|
computed: {
|
...mapState({
|
sidebar: state => state.app.sidebar,
|
device: state => state.app.device,
|
}),
|
classObj() {
|
return {
|
hideSidebar: !this.sidebar.opened,
|
openSidebar: this.sidebar.opened,
|
withoutAnimation: this.sidebar.withoutAnimation,
|
mobile: this.device === 'mobile'
|
}
|
}
|
},
|
methods: {
|
handleClickOutside() {
|
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
},
|
onWSMessage1: function(res) {
|
//console.log(res)
|
let resData = JSON.parse(res.data);
|
if (!resData.data.checkLogin.data) {
|
this.$layer.msg(resData.data.checkLogin.msg);
|
this.$store.dispatch('user/logout');
|
setTimeout(() => {
|
this.$router.push("/login");
|
location.reload();
|
}, 2000);
|
}
|
},
|
onWSOpen1: function() {
|
console.log("通讯成功");
|
},
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
.app-wrapper {
|
display: flex;
|
height: 100%;
|
.main-container {
|
flex: 1;
|
position: relative;
|
.inner {
|
position: absolute;
|
left: 0;
|
top: 0;
|
right: 0;
|
bottom: 0;
|
}
|
}
|
}
|
|
.main-container-wrapper {
|
height: 100%;
|
display: flex;
|
flex-direction: column;
|
.main-container-content {
|
flex: 1;
|
overflow-y: auto;
|
}
|
}
|
</style>
|