index.vue 2.2 KB

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