Layout.vue 1.42 KB
Newer Older
Pan's avatar
Pan committed
1
<template>
2 3 4
  <div :class="classObj" class="app-wrapper">
    <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
    <sidebar class="sidebar-container"/>
Pan's avatar
Pan committed
5
    <div class="main-container">
6 7
      <navbar/>
      <app-main/>
Pan's avatar
Pan committed
8 9
    </div>
  </div>
Pan's avatar
Pan committed
10 11 12
</template>

<script>
13 14
import { Navbar, Sidebar, AppMain } from './components'
import ResizeMixin from './mixin/ResizeHandler'
Pan's avatar
Pan committed
15

Pan's avatar
Pan committed
16
export default {
17
  name: 'Layout',
Pan's avatar
Pan committed
18 19 20 21 22
  components: {
    Navbar,
    Sidebar,
    AppMain
  },
23
  mixins: [ResizeMixin],
Pan's avatar
Pan committed
24 25 26
  computed: {
    sidebar() {
      return this.$store.state.app.sidebar
27 28 29 30 31 32 33
    },
    device() {
      return this.$store.state.app.device
    },
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
34
        openSidebar: this.sidebar.opened,
35 36 37
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === 'mobile'
      }
Pan's avatar
Pan committed
38
    }
39 40 41 42 43
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch('CloseSideBar', { withoutAnimation: false })
    }
Pan's avatar
Pan committed
44 45
  }
}
Pan's avatar
Pan committed
46 47 48
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
49 50 51 52 53 54
  @import "src/styles/mixin.scss";
  .app-wrapper {
    @include clearfix;
    position: relative;
    height: 100%;
    width: 100%;
55 56 57 58
    &.mobile.openSidebar{
      position: fixed;
      top: 0;
    }
59
  }
60 61 62 63 64 65 66 67 68
  .drawer-bg {
    background: #000;
    opacity: 0.3;
    width: 100%;
    top: 0;
    height: 100%;
    position: absolute;
    z-index: 999;
  }
Pan's avatar
Pan committed
69
</style>