index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 />
  8. <tags-view v-if="needTagsView" />
  9. </div>
  10. <app-main />
  11. <right-panel>
  12. <settings />
  13. </right-panel>
  14. </div>
  15. <el-dialog title="联系我们" :visible.sync="dialogVisible" width="30%">
  16. <img width="100%" src="../assets/images/wx.jpg" alt="">
  17. </el-dialog>
  18. </div>
  19. </template>
  20. <script>
  21. import RightPanel from '@/components/RightPanel'
  22. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  23. import ResizeMixin from './mixin/ResizeHandler'
  24. import { mapState } from 'vuex'
  25. import variables from '@/assets/styles/variables.scss'
  26. export default {
  27. name: 'Layout',
  28. data() {
  29. return {
  30. dialogVisible: false,
  31. }
  32. },
  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. fatherMethod() {
  65. this.dialogVisible = true;
  66. },
  67. handleClickOutside() {
  68. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. @import "~@/assets/styles/mixin.scss";
  75. @import "~@/assets/styles/variables.scss";
  76. .app-wrapper {
  77. @include clearfix;
  78. position: relative;
  79. height: 100%;
  80. width: 100%;
  81. &.mobile.openSidebar {
  82. position: fixed;
  83. top: 0;
  84. }
  85. }
  86. .drawer-bg {
  87. background: #000;
  88. opacity: 0.3;
  89. width: 100%;
  90. top: 0;
  91. height: 100%;
  92. position: absolute;
  93. z-index: 999;
  94. }
  95. .fixed-header {
  96. position: fixed;
  97. top: 0;
  98. right: 0;
  99. z-index: 9;
  100. width: calc(100% - #{$base-sidebar-width});
  101. transition: width 0.28s;
  102. }
  103. .hideSidebar .fixed-header {
  104. // width: calc(100% - 54px);
  105. width: calc(100% - 0px);
  106. }
  107. .sidebarHide .fixed-header {
  108. width: calc(100%);
  109. }
  110. .mobile .fixed-header {
  111. width: 100%;
  112. }
  113. </style>