index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <!-- :class="classObj" -->
  3. <div class="app-wrapper">
  4. <div v-if="device==='mobile'&&sidebar.opened"
  5. class="drawer-bg"
  6. @click="handleClickOutside" />
  7. <sidebar class="sidebar-container" />
  8. <div class="main-container">
  9. <div :class="{'fixed-header':fixedHeader}">
  10. <navbar />
  11. </div>
  12. <app-main />
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { Navbar, Sidebar, AppMain } from './components'
  18. import ResizeMixin from './mixin/ResizeHandler'
  19. export default {
  20. name: 'Layout',
  21. components: {
  22. Navbar,
  23. Sidebar,
  24. AppMain
  25. },
  26. mixins: [ResizeMixin],
  27. computed: {
  28. sidebar () {
  29. return this.$store.state.app.sidebar
  30. },
  31. device () {
  32. return this.$store.state.app.device
  33. },
  34. fixedHeader () {
  35. return this.$store.state.settings.fixedHeader
  36. },
  37. classObj () {
  38. return {
  39. hideSidebar: false,
  40. openSidebar: this.sidebar.opened,
  41. // withoutAnimation: this.sidebar.withoutAnimation,
  42. // mobile: this.device === 'mobile'
  43. }
  44. }
  45. },
  46. methods: {
  47. handleClickOutside () {
  48. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. @import "~@/styles/mixin.scss";
  55. @import "~@/styles/variables.scss";
  56. .app-wrapper {
  57. @include clearfix;
  58. position: relative;
  59. // height: 100vh;
  60. width: 100%;
  61. &.mobile.openSidebar {
  62. position: fixed;
  63. top: 0;
  64. }
  65. }
  66. .drawer-bg {
  67. background: #000;
  68. opacity: 0.3;
  69. width: 100%;
  70. top: 0;
  71. height: 100%;
  72. position: absolute;
  73. z-index: 999;
  74. }
  75. .fixed-header {
  76. position: fixed;
  77. top: 0;
  78. right: 0;
  79. z-index: 11111;
  80. width: calc(100% - #{$sideBarWidth});
  81. transition: width 0.28s;
  82. }
  83. .hideSidebar .fixed-header {
  84. width: calc(100% - 54px);
  85. }
  86. .mobile .fixed-header {
  87. width: 100%;
  88. }
  89. .main-container {
  90. // overflow:
  91. padding: 10px 10px 0 0;
  92. // background-color: #fff;
  93. box-sizing: border-box;
  94. }
  95. </style>