index.vue 2.0 KB

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