index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div
  3. :class="classObj"
  4. class="app-wrapper"
  5. :style="{ '--current-color': theme }"
  6. >
  7. <div
  8. v-if="device === 'mobile' && sidebar.opened"
  9. class="drawer-bg"
  10. @click="handleClickOutside"
  11. />
  12. <sidebar class="sidebar-container" />
  13. <div :class="{ hasTagsView: needTagsView }" class="main-container">
  14. <div :class="{ 'fixed-header': fixedHeader }" id="box">
  15. <navbar />
  16. <tags-view v-if="needTagsView" />
  17. </div>
  18. <app-main />
  19. <right-panel>
  20. <settings />
  21. </right-panel>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import RightPanel from "@/components/RightPanel";
  27. import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
  28. import ResizeMixin from "./mixin/ResizeHandler";
  29. import { mapState } from "vuex";
  30. import variables from "@/assets/styles/variables.scss";
  31. export default {
  32. name: "Layout",
  33. components: {
  34. AppMain,
  35. Navbar,
  36. RightPanel,
  37. Settings,
  38. Sidebar,
  39. TagsView,
  40. },
  41. mixins: [ResizeMixin],
  42. computed: {
  43. ...mapState({
  44. theme: (state) => state.settings.theme,
  45. sideTheme: (state) => state.settings.sideTheme,
  46. sidebar: (state) => state.app.sidebar,
  47. device: (state) => state.app.device,
  48. needTagsView: (state) => state.settings.tagsView,
  49. fixedHeader: (state) => state.settings.fixedHeader,
  50. }),
  51. classObj() {
  52. return {
  53. hideSidebar: !this.sidebar.opened,
  54. openSidebar: this.sidebar.opened,
  55. withoutAnimation: this.sidebar.withoutAnimation,
  56. mobile: this.device === "mobile",
  57. };
  58. },
  59. variables() {
  60. return variables;
  61. },
  62. },
  63. methods: {
  64. handleClickOutside() {
  65. this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
  66. },
  67. },
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. @import "~@/assets/styles/mixin.scss";
  72. @import "~@/assets/styles/variables.scss";
  73. .app-wrapper {
  74. @include clearfix;
  75. position: relative;
  76. height: 100%;
  77. width: 100%;
  78. &.mobile.openSidebar {
  79. position: fixed;
  80. top: 0;
  81. }
  82. }
  83. .drawer-bg {
  84. background: #000;
  85. opacity: 0.3;
  86. width: 100%;
  87. top: 0;
  88. height: 100%;
  89. position: absolute;
  90. z-index: 999;
  91. }
  92. .fixed-header {
  93. position: fixed;
  94. top: 0;
  95. right: 0;
  96. z-index: 9;
  97. width: calc(100% - #{$base-sidebar-width});
  98. transition: width 0.28s;
  99. }
  100. .hideSidebar .fixed-header {
  101. width: calc(100% - 54px);
  102. }
  103. .mobile .fixed-header {
  104. width: 100%;
  105. }
  106. .main-container{
  107. position: relative;
  108. }
  109. #box{
  110. position: sticky;
  111. top: 0px;
  112. z-index: 999;
  113. }
  114. </style>