index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div
  3. :class="classObj"
  4. class="app-wrapper"
  5. >
  6. <sidebar class="sidebar-container" />
  7. <navbar @initMessage="initMessage" />
  8. <div
  9. :class="{hasTagsView:needTagsView}"
  10. class="main-container"
  11. >
  12. <div :class="{'fixed-header':fixedHeader}">
  13. <tags-view v-if="needTagsView" />
  14. </div>
  15. <app-main ref="main-container" />
  16. <right-panel v-if="showSettings">
  17. <settings />
  18. </right-panel>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import RightPanel from '@/components/RightPanel'
  24. import { AppMain, Navbar, Sidebar, TagsView, Settings } from './components'
  25. import ResizeMixin from './mixin/ResizeHandler'
  26. import { mapState, mapGetters } from 'vuex'
  27. export default {
  28. name: 'LayoutIndex',
  29. components: {
  30. AppMain,
  31. Navbar,
  32. Sidebar,
  33. TagsView,
  34. Settings,
  35. RightPanel
  36. },
  37. mixins: [ResizeMixin],
  38. computed: {
  39. ...mapState({
  40. sidebar: state => state.app.sidebar,
  41. device: state => state.app.device,
  42. showSettings: state => state.settings.showSettings,
  43. needTagsView: state => state.settings.tagsView,
  44. fixedHeader: state => state.settings.fixedHeader
  45. }),
  46. ...mapGetters([
  47. 'permission_routes'
  48. ]),
  49. classObj() {
  50. return {
  51. hideSidebar: !this.sidebar.opened,
  52. openSidebar: this.sidebar.opened,
  53. withoutAnimation: this.sidebar.withoutAnimation,
  54. mobile: this.device === 'mobile',
  55. withoutMenu: this.withoutMenu()
  56. }
  57. }
  58. },
  59. methods: {
  60. handleClickOutside() {
  61. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  62. },
  63. initMessage() {
  64. this.$nextTick(() => {
  65. this.$refs['main-container'].showMessage()
  66. })
  67. },
  68. withoutMenu() {
  69. const routes = this.permission_routes.filter(item => !item.hidden)
  70. const len = this.permission_routes.filter(item => !item.hidden).length
  71. if (len > 1) return false
  72. if (len === 1) {
  73. return routes[0].children.filter(item => !item.hidden).length <= 1
  74. }
  75. return true
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. @import "~@/styles/mixin.scss";
  82. @import "~@/styles/variables.scss";
  83. .app-wrapper {
  84. @include clearfix;
  85. position: relative;
  86. height: 100%;
  87. width: 100%;
  88. // background-image: url("../assets/images/login/login_background.jpg");
  89. background-repeat: no-repeat;
  90. background-color: #071A29;
  91. &.mobile.openSidebar {
  92. position: fixed;
  93. top: 0;
  94. }
  95. }
  96. .drawer-bg {
  97. background: #000;
  98. opacity: 0.3;
  99. width: 100%;
  100. top: 0;
  101. height: 100%;
  102. position: absolute;
  103. z-index: 999;
  104. }
  105. .fixed-header {
  106. position: fixed;
  107. top: 0;
  108. right: 0;
  109. z-index: 9;
  110. width: calc(100% - #{$sideBarWidth});
  111. transition: width 0.28s;
  112. }
  113. .hideSidebar .fixed-header {
  114. width: calc(100% - 54px)
  115. }
  116. .mobile .fixed-header {
  117. width: 100%;
  118. }
  119. #app{
  120. .withoutMenu {
  121. .sidebar-container{
  122. display: none;
  123. }
  124. .main-container{
  125. margin-left: 0;
  126. }
  127. }
  128. }
  129. </style>