blob: df7af871d02f0e3f4a1be27ca5d4b8890354f138 [file] [log] [blame]
huibing.xie1f1606f2018-08-20 15:46:55 +08001<template>
2 <div class="app-wrapper" :class="classObj">
3 <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"></div>
4 <sidebar class="sidebar-container"></sidebar>
5 <div class="main-container">
6 <navbar></navbar>
7 <tags-view v-if='showtags'></tags-view>
8 <app-main></app-main>
9 </div>
10 </div>
11</template>
12
13<script>
14import { Navbar, Sidebar, AppMain, TagsView } from './components'
15import ResizeMixin from './mixin/ResizeHandler'
16
17export default {
18 name: 'layout',
19 components: {
20 Navbar,
21 Sidebar,
22 AppMain,
23 TagsView
24 },
25 mixins: [ResizeMixin],
26 computed: {
27 showtags() {
28 return process.env.SHOW_TAGS
29 },
30 sidebar() {
31 return this.$store.state.app.sidebar
32 },
33 device() {
34 return this.$store.state.app.device
35 },
36 classObj() {
37 return {
38 hideSidebar: !this.sidebar.opened,
39 openSidebar: this.sidebar.opened,
40 withoutAnimation: this.sidebar.withoutAnimation,
41 mobile: this.device === 'mobile'
42 }
43 }
44 },
45 methods: {
46 handleClickOutside() {
47 this.$store.dispatch('CloseSideBar', { withoutAnimation: false })
48 }
49 }
50}
51</script>
52
53<style rel="stylesheet/scss" lang="scss" scoped>
54 @import "src/styles/mixin.scss";
55 .app-wrapper {
56 @include clearfix;
57 position: relative;
58 height: 100%;
59 width: 100%;
60 &.mobile.openSidebar{
61 position: fixed;
62 top: 0;
63 }
64 }
65 .drawer-bg {
66 background: #000;
67 opacity: 0.3;
68 width: 100%;
69 top: 0;
70 height: 100%;
71 position: absolute;
72 z-index: 999;
73 }
74</style>