Layout.vue 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="app-wrapper" :class="classObj">
  3. <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside"></div>
  4. <navbar></navbar>
  5. <div class="Header-container">
  6. <sidebar class="sidebar-container" @callBackIndex="handleIndex"></sidebar>
  7. <!-- <sidebar class="newSide" @callBackIndex="handleIndex"></sidebar> -->
  8. <div class="main-container">
  9. <tags-view :index="index" :num="num"></tags-view>
  10. <app-main></app-main>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import { Navbar, Sidebar, AppMain, TagsView } from "./components";
  17. import ResizeMixin from "./mixin/ResizeHandler";
  18. export default {
  19. name: "layout",
  20. components: {
  21. Navbar,
  22. Sidebar,
  23. AppMain,
  24. TagsView
  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. classObj() {
  35. return {
  36. hideSidebar: !this.sidebar.opened,
  37. openSidebar: this.sidebar.opened,
  38. withoutAnimation: this.sidebar.withoutAnimation,
  39. mobile: this.device === "mobile"
  40. };
  41. }
  42. },
  43. data() {
  44. return {
  45. index: 0,
  46. num: 1
  47. };
  48. },
  49. methods: {
  50. handleClickOutside() {
  51. this.$store.dispatch("closeSideBar", { withoutAnimation: false });
  52. },
  53. handleIndex(data, num) {
  54. // console.log({ prop: data });
  55. this.index = data;
  56. this.num = num;
  57. }
  58. }
  59. };
  60. </script>
  61. <style rel="stylesheet/scss" lang="scss" scoped>
  62. @import "src/styles/mixin.scss";
  63. .app-wrapper {
  64. @include clearfix;
  65. // position: relative;
  66. height: 100%;
  67. width: 100%;
  68. // &.mobile.openSidebar{
  69. // position: fixed;
  70. // top: 0;
  71. // }
  72. }
  73. .drawer-bg {
  74. background: #000;
  75. opacity: 0.3;
  76. width: 100%;
  77. top: 0;
  78. height: 100%;
  79. position: absolute;
  80. z-index: 999;
  81. }
  82. .newSide {
  83. width: 150px !important;
  84. height: 100%;
  85. position: fixed;
  86. top: 60px;
  87. bottom: 0;
  88. left: 0;
  89. z-index: 1001;
  90. overflow: hidden;
  91. }
  92. </style>
  93. <style lang="scss">
  94. </style>