index.vue 3.4 KB

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