index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div :class="classObj" class="app-wrapper">
  3. <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <sidebar class="sidebar-container" />
  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. export default {
  23. name: 'Layout',
  24. components: {
  25. AppMain,
  26. Navbar,
  27. RightPanel,
  28. Settings,
  29. Sidebar,
  30. TagsView
  31. },
  32. mixins: [ResizeMixin],
  33. computed: {
  34. ...mapState({
  35. sidebar: state => state.app.sidebar,
  36. device: state => state.app.device,
  37. showSettings: state => state.settings.showSettings,
  38. needTagsView: state => state.settings.tagsView,
  39. fixedHeader: state => state.settings.fixedHeader
  40. }),
  41. classObj() {
  42. return {
  43. hideSidebar: !this.sidebar.opened,
  44. openSidebar: this.sidebar.opened,
  45. withoutAnimation: this.sidebar.withoutAnimation,
  46. mobile: this.device === 'mobile'
  47. }
  48. }
  49. },
  50. methods: {
  51. handleClickOutside() {
  52. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. @import "~@/styles/mixin.scss";
  59. @import "~@/styles/variables.scss";
  60. .app-wrapper {
  61. @include clearfix;
  62. position: relative;
  63. height: 100%;
  64. width: 100%;
  65. &.mobile.openSidebar {
  66. position: fixed;
  67. top: 0;
  68. }
  69. }
  70. .drawer-bg {
  71. background: #000;
  72. opacity: 0.3;
  73. width: 100%;
  74. top: 0;
  75. height: 100%;
  76. position: absolute;
  77. z-index: 999;
  78. }
  79. .fixed-header {
  80. position: fixed;
  81. top: 0;
  82. right: 0;
  83. z-index: 9;
  84. width: calc(100% - #{$sideBarWidth});
  85. transition: width 0.28s;
  86. }
  87. .hideSidebar .fixed-header {
  88. width: calc(100% - 54px)
  89. }
  90. .mobile .fixed-header {
  91. width: 100%;
  92. }
  93. </style>