index.vue 2.5 KB

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