index.vue 2.6 KB

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