index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 v-if="!sidebar.hide" class="sidebar-container" />
  5. <div :class="{hasTagsView:needTagsView,sidebarHide:sidebar.hide}" 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>
  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. needTagsView: state => state.settings.tagsView,
  41. fixedHeader: state => state.settings.fixedHeader
  42. }),
  43. classObj() {
  44. return {
  45. hideSidebar: !this.sidebar.opened,
  46. openSidebar: this.sidebar.opened,
  47. withoutAnimation: this.sidebar.withoutAnimation,
  48. mobile: this.device === 'mobile'
  49. }
  50. },
  51. variables() {
  52. return variables;
  53. }
  54. },
  55. methods: {
  56. handleClickOutside() {
  57. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. @import "~@/assets/styles/mixin.scss";
  64. @import "~@/assets/styles/variables.scss";
  65. .app-wrapper {
  66. @include clearfix;
  67. position: relative;
  68. height: 100%;
  69. width: 100%;
  70. &.mobile.openSidebar {
  71. position: fixed;
  72. top: 0;
  73. }
  74. }
  75. .drawer-bg {
  76. background: #000;
  77. opacity: 0.3;
  78. width: 100%;
  79. top: 0;
  80. height: 100%;
  81. position: absolute;
  82. z-index: 999;
  83. }
  84. .fixed-header {
  85. position: fixed;
  86. top: 0;
  87. right: 0;
  88. z-index: 9;
  89. width: calc(100% - #{$base-sidebar-width});
  90. transition: width 0.28s;
  91. }
  92. .hideSidebar .fixed-header {
  93. width: calc(100% - 54px);
  94. }
  95. .sidebarHide .fixed-header {
  96. width: 100%;
  97. }
  98. .mobile .fixed-header {
  99. width: 100%;
  100. }
  101. </style>