index.vue 2.0 KB

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