猫妈狗爸伴宠师小程序后端代码
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.

124 lines
2.8 KiB

3 months ago
  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. </div>
  16. </template>
  17. <script>
  18. import RightPanel from '@/components/RightPanel'
  19. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  20. import ResizeMixin from './mixin/ResizeHandler'
  21. import { mapState } from 'vuex'
  22. import variables from '@/assets/styles/variables.scss'
  23. export default {
  24. name: 'Layout',
  25. components: {
  26. AppMain,
  27. Navbar,
  28. RightPanel,
  29. Settings,
  30. Sidebar,
  31. TagsView
  32. },
  33. mixins: [ResizeMixin],
  34. computed: {
  35. ...mapState({
  36. theme: state => state.settings.theme,
  37. sideTheme: state => state.settings.sideTheme,
  38. sidebar: state => state.app.sidebar,
  39. device: state => state.app.device,
  40. needTagsView: state => state.settings.tagsView,
  41. fixedHeader: state => state.settings.fixedHeader
  42. }),
  43. classObj() {
  44. return {
  45. hideSidebar: !this.sidebar.opened,
  46. openSidebar: this.sidebar.opened,
  47. withoutAnimation: this.sidebar.withoutAnimation,
  48. mobile: this.device === 'mobile'
  49. }
  50. },
  51. variables() {
  52. return variables;
  53. }
  54. },
  55. created() {
  56. this.$store.dispatch('loadDictionaries')
  57. },
  58. methods: {
  59. handleClickOutside() {
  60. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. @import "~@/assets/styles/mixin.scss";
  67. @import "~@/assets/styles/variables.scss";
  68. .app-wrapper {
  69. @include clearfix;
  70. position: relative;
  71. height: 100%;
  72. width: 100%;
  73. &.mobile.openSidebar {
  74. position: fixed;
  75. top: 0;
  76. }
  77. }
  78. .drawer-bg {
  79. background: #000;
  80. opacity: 0.3;
  81. width: 100%;
  82. top: 0;
  83. height: 100%;
  84. position: absolute;
  85. z-index: 999;
  86. }
  87. .fixed-header {
  88. position: fixed;
  89. top: 0;
  90. right: 0;
  91. z-index: 9;
  92. width: calc(100% - #{$base-sidebar-width});
  93. transition: width 0.28s;
  94. }
  95. .hideSidebar .fixed-header {
  96. width: calc(100% - 54px);
  97. }
  98. .sidebarHide .fixed-header {
  99. width: 100%;
  100. }
  101. .mobile .fixed-header {
  102. width: 100%;
  103. }
  104. #footer-global {
  105. position: fixed;
  106. right: 0;
  107. bottom: 0;
  108. padding: 12px;
  109. box-shadow: -1px 0 12px 0 var(--gray-5);
  110. transition: all .28s;
  111. background-color: white;
  112. z-index: 100;
  113. }
  114. </style>