index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <right-panel v-if="showSettings">
  16. <settings />
  17. </right-panel>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. // import RightPanel from '@/components/RightPanel'
  23. import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
  24. import ResizeMixin from "./mixin/ResizeHandler";
  25. import { mapState } from "vuex";
  26. export default {
  27. name: "Layout",
  28. components: {
  29. AppMain,
  30. Navbar,
  31. // RightPanel,
  32. Settings,
  33. Sidebar,
  34. TagsView,
  35. },
  36. mixins: [ResizeMixin],
  37. computed: {
  38. ...mapState({
  39. sidebar: (state) => state.app.sidebar,
  40. device: (state) => state.app.device,
  41. showSettings: (state) => state.settings.showSettings,
  42. needTagsView: (state) => state.settings.tagsView,
  43. fixedHeader: (state) => state.settings.fixedHeader,
  44. }),
  45. classObj() {
  46. return {
  47. hideSidebar: !this.sidebar.opened,
  48. openSidebar: this.sidebar.opened,
  49. withoutAnimation: this.sidebar.withoutAnimation,
  50. mobile: this.device === "mobile",
  51. };
  52. },
  53. },
  54. methods: {
  55. handleClickOutside() {
  56. this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
  57. },
  58. },
  59. };
  60. </script>
  61. <style lang="scss" scoped>
  62. @import "~@/styles/mixin.scss";
  63. @import "~@/styles/variables.scss";
  64. .app-wrapper {
  65. @include clearfix;
  66. height: 100%;
  67. width: 100%;
  68. position: fixed;
  69. overflow: hidden;
  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% - #{$sideBarWidth});
  90. transition: width 0.28s;
  91. }
  92. .hideSidebar .fixed-header {
  93. width: calc(100% - 54px);
  94. }
  95. .mobile .fixed-header {
  96. width: 100%;
  97. }
  98. </style>