【前端】智能库房综合管理系统前端项目
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.

148 lines
3.6 KiB

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