index.vue 2.7 KB

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