index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div
  3. :class="classObj"
  4. class="app-wrapper"
  5. :style="{ '--current-color': theme }"
  6. >
  7. <div
  8. v-if="device === 'mobile' && sidebar.opened"
  9. class="drawer-bg"
  10. @click="handleClickOutside"
  11. />
  12. <sidebar v-if="!sidebar.hide" class="sidebar-container" />
  13. <!-- <Menu></Menu>-->
  14. <div
  15. :class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }"
  16. class="main-container"
  17. >
  18. <div :class="{ 'fixed-header': fixedHeader }">
  19. <Top></Top>
  20. <navbar />
  21. <tags-view v-if="needTagsView" />
  22. </div>
  23. <app-main />
  24. <right-panel>
  25. <settings />
  26. </right-panel>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import RightPanel from "@/components/RightPanel";
  32. import Top from "./components/Top";
  33. import Menu from "./components/Menu";
  34. import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
  35. import ResizeMixin from "./mixin/ResizeHandler";
  36. import { mapState } from "vuex";
  37. import variables from "@/assets/styles/variables.scss";
  38. export default {
  39. name: "Layout",
  40. components: {
  41. AppMain,
  42. Navbar,
  43. RightPanel,
  44. Settings,
  45. Sidebar,
  46. TagsView,
  47. Top,
  48. Menu,
  49. },
  50. mixins: [ResizeMixin],
  51. computed: {
  52. ...mapState({
  53. theme: (state) => state.settings.theme,
  54. sideTheme: (state) => state.settings.sideTheme,
  55. sidebar: (state) => state.app.sidebar,
  56. device: (state) => state.app.device,
  57. needTagsView: (state) => state.settings.tagsView,
  58. fixedHeader: (state) => state.settings.fixedHeader,
  59. }),
  60. classObj() {
  61. return {
  62. hideSidebar: !this.sidebar.opened,
  63. openSidebar: this.sidebar.opened,
  64. withoutAnimation: this.sidebar.withoutAnimation,
  65. mobile: this.device === "mobile",
  66. };
  67. },
  68. variables() {
  69. return variables;
  70. },
  71. },
  72. created() {
  73. console.log(this.$route.path, "x");
  74. },
  75. methods: {
  76. handleClickOutside() {
  77. this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
  78. },
  79. },
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. @import "~@/assets/styles/mixin.scss";
  84. @import "~@/assets/styles/variables.scss";
  85. .app-wrapper {
  86. @include clearfix;
  87. position: relative;
  88. height: 100%;
  89. width: 100%;
  90. &.mobile.openSidebar {
  91. position: fixed;
  92. top: 0;
  93. }
  94. }
  95. //#app .app-wrapper .sidebar-container {
  96. // position: relative;
  97. // width: 100% !important;
  98. // height: 80px;
  99. //}
  100. //
  101. #app .main-container {
  102. //margin: 0;
  103. height: calc(100% - 130px);
  104. }
  105. //
  106. //.drawer-bg {
  107. // background: #000;
  108. // opacity: 0.3;
  109. // width: 100%;
  110. // top: 0;
  111. // height: 100%;
  112. // position: absolute;
  113. // z-index: 999;
  114. //}
  115. //
  116. //.fixed-header {
  117. // position: fixed;
  118. // top: 0;
  119. // right: 0;
  120. // z-index: 9;
  121. // width: calc(100% - #{$base-sidebar-width});
  122. // transition: width 0.28s;
  123. //}
  124. //
  125. //.hideSidebar .fixed-header {
  126. // width: calc(100% - 54px);
  127. //}
  128. //
  129. //.sidebarHide .fixed-header {
  130. // width: 100%;
  131. //}
  132. //
  133. //.mobile .fixed-header {
  134. // width: 100%;
  135. //}
  136. </style>