index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. created() {
  64. console.log('isWideScreen',this.isWideScreen)
  65. },
  66. computed: {
  67. ...mapState({
  68. theme: (state) => state.settings.theme,
  69. sideTheme: (state) => state.settings.sideTheme,
  70. sidebar: (state) => state.app.sidebar,
  71. device: (state) => state.app.device,
  72. showSettings: (state) => state.settings.showSettings,
  73. needTagsView: (state) => state.settings.tagsView,
  74. fixedHeader: (state) => state.settings.fixedHeader,
  75. }),
  76. ...mapGetters(["sidebarRouters", "sidebar", "isWideScreen"]),
  77. classObj() {
  78. return {
  79. // hideSidebar: !this.sidebar.opened,
  80. // openSidebar: this.sidebar.opened,
  81. openSidebar: this.sidebarRouters && this.sidebarRouters.length > 0,
  82. // withoutAnimation: this.sidebar.withoutAnimation,
  83. // mobile: this.device === 'mobile',
  84. hideSidebarNone:
  85. !this.sidebarRouters || this.sidebarRouters.length == 0,
  86. };
  87. },
  88. variables() {
  89. return variables;
  90. },
  91. },
  92. methods: {
  93. handleClickOutside() {
  94. this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
  95. },
  96. },
  97. };
  98. </script>
  99. <style lang="scss" scoped>
  100. @import "~@/assets/styles/mixin.scss";
  101. @import "~@/assets/styles/variables.scss";
  102. .app-wrapper {
  103. @include clearfix;
  104. position: relative;
  105. height: 100%;
  106. width: 100%;
  107. &.mobile.openSidebar {
  108. position: fixed;
  109. top: 0;
  110. }
  111. }
  112. .drawer-bg {
  113. background: #000;
  114. opacity: 0.3;
  115. width: 100%;
  116. top: 0;
  117. height: 100%;
  118. position: absolute;
  119. z-index: 999;
  120. }
  121. .fixed-header {
  122. position: fixed;
  123. top: 0;
  124. right: 0;
  125. z-index: 9;
  126. width: calc(100% - #{$sideBarWidth});
  127. transition: width 0.28s;
  128. }
  129. .hideSidebar .fixed-header {
  130. width: calc(100% - 54px)
  131. }
  132. .mobile .fixed-header {
  133. width: 100%;
  134. }
  135. .sidebar-container{
  136. z-index:8 !important;
  137. margin-top: 90px;
  138. }
  139. .main-container{
  140. padding-top: 90px;
  141. }
  142. .max-mainWidth{
  143. max-width:1340px;
  144. margin:auto
  145. }
  146. </style>