Rap 原分销系统代码Web
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

36c8769dcc6d55f4045b2b71e30848e024132a65.svn-base 2.6KB

5 个月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div :class="classObj" class="app-wrapper">
  3. <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <sidebar class="sidebar-container" />
  5. <div :class="{hasTagsView:needTagsView}" 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 v-if="showSettings">
  12. <settings />
  13. </right-panel>
  14. </div>
  15. <!-- 防止刷新后主题丢失 -->
  16. <Theme v-show="false" ref="theme" />
  17. </div>
  18. </template>
  19. <script>
  20. import RightPanel from '@/components/RightPanel'
  21. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  22. import ResizeMixin from './mixin/ResizeHandler'
  23. import { mapState } from 'vuex'
  24. import Theme from '@/components/ThemePicker'
  25. import Cookies from 'js-cookie'
  26. export default {
  27. name: 'Layout',
  28. components: {
  29. AppMain,
  30. Navbar,
  31. RightPanel,
  32. Settings,
  33. Sidebar,
  34. TagsView,
  35. Theme
  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. classObj() {
  47. return {
  48. hideSidebar: !this.sidebar.opened,
  49. openSidebar: this.sidebar.opened,
  50. withoutAnimation: this.sidebar.withoutAnimation,
  51. mobile: this.device === 'mobile'
  52. }
  53. }
  54. },
  55. mounted() {
  56. if (Cookies.get('theme')) {
  57. this.$refs.theme.theme = Cookies.get('theme')
  58. this.$store.dispatch('settings/changeSetting', {
  59. key: 'theme',
  60. value: Cookies.get('theme')
  61. })
  62. }
  63. },
  64. methods: {
  65. handleClickOutside() {
  66. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. @import "~@/assets/styles/mixin.scss";
  73. @import "~@/assets/styles/variables.scss";
  74. .app-wrapper {
  75. @include clearfix;
  76. position: relative;
  77. height: 100%;
  78. width: 100%;
  79. &.mobile.openSidebar {
  80. position: fixed;
  81. top: 0;
  82. }
  83. }
  84. .drawer-bg {
  85. background: #000;
  86. opacity: 0.3;
  87. width: 100%;
  88. top: 0;
  89. height: 100%;
  90. position: absolute;
  91. z-index: 999;
  92. }
  93. .fixed-header {
  94. position: fixed;
  95. top: 0;
  96. right: 0;
  97. z-index: 9;
  98. width: calc(100% - #{$sideBarWidth});
  99. transition: width 0.28s;
  100. padding: 0;
  101. }
  102. .hideSidebar .fixed-header {
  103. width: calc(100% - 54px)
  104. }
  105. .mobile .fixed-header {
  106. width: 100%;
  107. }
  108. </style>