index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 && handleNavigationBarShow()" class="sidebar-container"/>
  6. <div :class="{hasTagsView:needTagsView,sidebarHide:sidebar.hide}" class="main-container" :style="cssVar">
  7. <div v-if="handleNavigationBarShow()" :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. cssVar(){
  57. return {
  58. 'margin-left': this.handleNavigationBarShow() ? '54px': '0px'
  59. }
  60. },
  61. },
  62. methods: {
  63. handleClickOutside() {
  64. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  65. },
  66. handleNavigationBarShow(){
  67. if(process.env.NODE_ENV === 'development'){
  68. return true;
  69. }
  70. return false;
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. @import "~@/assets/styles/mixin.scss";
  77. @import "~@/assets/styles/variables.scss";
  78. // #app .hideSidebar .main-container{
  79. // margin-left: var(--left)!important;
  80. // }
  81. .app-wrapper {
  82. @include clearfix;
  83. position: relative;
  84. height: 100%;
  85. width: 100%;
  86. .el-scrollbar{
  87. height: 100%;
  88. }
  89. ::v-deep .el-scrollbar__wrap {
  90. overflow-x: hidden;
  91. }
  92. &.mobile.openSidebar {
  93. position: fixed;
  94. top: 0;
  95. }
  96. }
  97. .drawer-bg {
  98. background: #000;
  99. opacity: 0.3;
  100. width: 100%;
  101. top: 0;
  102. height: 100%;
  103. position: absolute;
  104. z-index: 999;
  105. }
  106. .fixed-header {
  107. position: fixed;
  108. top: 0;
  109. right: 0;
  110. z-index: 9;
  111. width: calc(100% - #{$base-sidebar-width});
  112. transition: width 0.28s;
  113. }
  114. .hideSidebar .fixed-header {
  115. width: calc(100% - 54px);
  116. }
  117. .sidebarHide .fixed-header {
  118. width: 100%;
  119. }
  120. .mobile .fixed-header {
  121. width: 100%;
  122. }
  123. </style>