index.vue 2.7 KB

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