Layout.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <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. <app-main></app-main>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import { Navbar, Sidebar, AppMain } from './components'
  13. import ResizeMixin from './mixin/ResizeHandler'
  14. export default {
  15. name: 'layout',
  16. components: {
  17. Navbar,
  18. Sidebar,
  19. AppMain
  20. },
  21. mixins: [ResizeMixin],
  22. computed: {
  23. sidebar() {
  24. return this.$store.state.app.sidebar
  25. },
  26. device() {
  27. return this.$store.state.app.device
  28. },
  29. classObj() {
  30. return {
  31. hideSidebar: !this.sidebar.opened,
  32. withoutAnimation: this.sidebar.withoutAnimation,
  33. mobile: this.device === 'mobile'
  34. }
  35. }
  36. },
  37. methods: {
  38. handleClickOutside() {
  39. this.$store.dispatch('CloseSideBar', { withoutAnimation: false })
  40. }
  41. }
  42. }
  43. </script>
  44. <style rel="stylesheet/scss" lang="scss" scoped>
  45. @import "src/styles/mixin.scss";
  46. .app-wrapper {
  47. @include clearfix;
  48. position: relative;
  49. height: 100%;
  50. width: 100%;
  51. }
  52. .drawer-bg {
  53. background: #000;
  54. opacity: 0.3;
  55. width: 100%;
  56. top: 0;
  57. height: 100%;
  58. position: absolute;
  59. z-index: 999;
  60. }
  61. </style>