index.vue 2.6 KB

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