UserHomeLayout.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="user-home-layout">
  3. <div class="main-container">
  4. <div class="menu-container-large">
  5. <template v-for="tab of tabs">
  6. <tab-icon-button
  7. :active="currentRouteName.match(tab.name)"
  8. :tab="tab"
  9. :key="tab.unicode"
  10. @click="handleIconButtonClick(tab.name)"
  11. :title="tab.title"
  12. >
  13. </tab-icon-button>
  14. </template>
  15. </div>
  16. <div class="tab-container">
  17. <keep-alive>
  18. <router-view/>
  19. </keep-alive>
  20. </div>
  21. </div>
  22. <div class="menu-container-small">
  23. <template v-for="tab of tabs">
  24. <tab-icon-button
  25. :active="currentRouteName.match(tab.name)"
  26. :tab="tab"
  27. :key="tab.unicode"
  28. @click="handleIconButtonClick(tab.name)"
  29. >
  30. </tab-icon-button>
  31. </template>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import TabIconButton from '@/components/TabIconButton'
  37. export default {
  38. components: { TabIconButton },
  39. props: ['tabs', 'role'],
  40. data () {
  41. return {
  42. currentRouteName: this.$route.name
  43. }
  44. },
  45. mounted () {
  46. this.resizeHandler()
  47. window.addEventListener('resize', this.resizeHandler)
  48. },
  49. destroyed () {
  50. window.removeEventListener('resize', this.resizeHandler)
  51. },
  52. watch: {
  53. $route () {
  54. this.currentRouteName = this.$route.path
  55. }
  56. },
  57. methods: {
  58. resizeHandler () {
  59. if (window.innerWidth < 900) {
  60. this.componentType = 'full-screen-component'
  61. } else {
  62. this.componentType = 'tab-side-component'
  63. }
  64. },
  65. handleIconButtonClick (name) {
  66. this.$router.push(`/${this.role}/${name}`)
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. @import '~@/style/theme.scss';
  73. .user-home-layout {
  74. height: 100vh;
  75. width: 100%;
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. }
  80. .main-container {
  81. display: flex;
  82. width: 100%;
  83. margin: 0 auto;
  84. justify-content: center;
  85. }
  86. // 大屏幕情况
  87. @media (min-width: 600px) {
  88. .menu-container-large {
  89. padding: 24px 18px;
  90. display: flex;
  91. flex-direction: column;
  92. justify-content: center;
  93. .tab-icon-button {
  94. margin: 16px 0;
  95. }
  96. }
  97. .tab-container {
  98. display: flex;
  99. padding: 24px 18px;
  100. max-width: 800px;
  101. }
  102. .menu-container-small {
  103. display: none;
  104. }
  105. }
  106. // 小屏幕情况
  107. @media (max-width: 599px) {
  108. .menu-container-large {
  109. display: none;
  110. }
  111. .tab-container {
  112. box-sizing: border-box;
  113. height: calc(100vh - 54px);
  114. padding: 48px 24px;
  115. margin-bottom: 30px;
  116. width: 100%;
  117. flex: 1;
  118. }
  119. .user-home-layout {
  120. justify-content: unset;
  121. min-height: calc(100vh - 54px);
  122. }
  123. .menu-container-small {
  124. z-index: 2;
  125. backdrop-filter: saturate(180%) blur(15px);
  126. background: rgba(255, 255, 255, 0.8);
  127. width: 100%;
  128. position: fixed;
  129. padding: 12px 0;
  130. height: 54px;
  131. box-sizing: border-box;
  132. bottom: 0;
  133. display: flex;
  134. align-items: center;
  135. justify-content: space-around;
  136. }
  137. .tab {
  138. min-width: unset;
  139. padding: unset;
  140. }
  141. }
  142. @supports (not(backdrop-filter: saturate(180%) blur(15px))) {
  143. .menu-container-small {
  144. background: rgb(255, 255, 255);
  145. }
  146. }
  147. </style>