index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div :class="classObj" class="app-wrapper">
  3. <div
  4. v-if="device === 'mobile' && sidebar.opened"
  5. class="drawer-bg"
  6. @click="handleClickOutside"
  7. />
  8. <sidebar class="sidebar-container" />
  9. <div :class="{ hasTagsView: needTagsView }" class="main-container">
  10. <div :class="{ 'fixed-header': fixedHeader }">
  11. <navbar />
  12. <tags-view v-if="needTagsView" />
  13. </div>
  14. <app-main />
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { AppMain, Navbar, 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. Sidebar,
  28. TagsView
  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>