阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div :class="classObj" class="app-wrapper">
  3. <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <div :class="{'fixed-header':fixedHeader}">
  5. <navbar />
  6. </div>
  7. <div :class="{hasTagsView:needTagsView}" class="main-container">
  8. <div class="main-breadcrumb">
  9. <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
  10. <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
  11. </div>
  12. <app-main />
  13. <right-panel v-if="showSettings">
  14. <settings />
  15. </right-panel>
  16. </div>
  17. <sidebar class="sidebar-container" />
  18. <!-- 防止刷新后主题丢失 -->
  19. <Theme v-show="false" ref="theme" />
  20. </div>
  21. </template>
  22. <script>
  23. import RightPanel from '@/components/RightPanel'
  24. import Breadcrumb from '@/components/Breadcrumb'
  25. import Hamburger from '@/components/Hamburger'
  26. import { AppMain, Navbar, Settings, Sidebar } from './components'
  27. import ResizeMixin from './mixin/ResizeHandler'
  28. import { mapState } from 'vuex'
  29. import Theme from '@/components/ThemePicker'
  30. import Cookies from 'js-cookie'
  31. export default {
  32. name: 'Layout',
  33. components: {
  34. AppMain,
  35. Navbar,
  36. RightPanel,
  37. Settings,
  38. Sidebar,
  39. Breadcrumb,
  40. Hamburger,
  41. Theme
  42. },
  43. mixins: [ResizeMixin],
  44. computed: {
  45. ...mapState({
  46. sidebar: state => state.app.sidebar,
  47. device: state => state.app.device,
  48. showSettings: state => state.settings.showSettings,
  49. needTagsView: state => state.settings.tagsView,
  50. fixedHeader: state => state.settings.fixedHeader
  51. }),
  52. classObj() {
  53. return {
  54. hideSidebar: !this.sidebar.opened,
  55. openSidebar: this.sidebar.opened,
  56. withoutAnimation: this.sidebar.withoutAnimation,
  57. mobile: this.device === 'mobile'
  58. }
  59. }
  60. },
  61. mounted() {
  62. if (Cookies.get('theme')) {
  63. this.$refs.theme.theme = Cookies.get('theme')
  64. this.$store.dispatch('settings/changeSetting', {
  65. key: 'theme',
  66. value: Cookies.get('theme')
  67. })
  68. }
  69. },
  70. methods: {
  71. handleClickOutside() {
  72. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  73. },
  74. toggleSideBar() {
  75. this.$store.dispatch('app/toggleSideBar')
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. @import "~@/assets/styles/mixin.scss";
  82. @import "~@/assets/styles/variables.scss";
  83. .app-wrapper {
  84. @include clearfix;
  85. position: relative;
  86. height: 100%;
  87. width: 100%;
  88. &.mobile.openSidebar {
  89. position: fixed;
  90. top: 0;
  91. }
  92. }
  93. .drawer-bg {
  94. background: #000;
  95. opacity: 0.3;
  96. width: 100%;
  97. top: 0;
  98. height: 100%;
  99. position: absolute;
  100. z-index: 999;
  101. }
  102. .fixed-header {
  103. position: fixed;
  104. top: 0;
  105. right: 0;
  106. z-index: 999;
  107. width: 100%;
  108. transition: width 0.28s;
  109. padding: 0;
  110. @include bg_color;
  111. @include shadow-set;
  112. }
  113. .mobile .fixed-header {
  114. width: 100%;
  115. }
  116. .main-breadcrumb{
  117. position: fixed;
  118. top: $headerHeight;
  119. left: $sideBarWidth;
  120. display: flex;
  121. justify-content:flex-start;
  122. width: 100%;
  123. @include breadcrumb-bg;
  124. @include shadow-set;
  125. z-index: 100;
  126. .hamburger-container {
  127. line-height: 48px;
  128. height: 100%;
  129. padding: 0 6px 0 20px;
  130. cursor: pointer;
  131. transition: background .3s;
  132. -webkit-tap-highlight-color:transparent;
  133. &:hover {
  134. background: rgba(0, 0, 0, .025)
  135. }
  136. }
  137. }
  138. </style>