| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template>
- <div class="user-home-layout">
- <div class="main-container">
- <div class="menu-container-large">
- <template v-for="tab of tabs">
- <tab-icon-button
- :active="currentRouteName.match(tab.name)"
- :tab="tab"
- :key="tab.unicode"
- @click="handleIconButtonClick(tab.name)"
- :title="tab.title"
- >
- </tab-icon-button>
- </template>
- </div>
- <div class="tab-container">
- <keep-alive>
- <router-view/>
- </keep-alive>
- </div>
- </div>
- <div class="menu-container-small">
- <template v-for="tab of tabs">
- <tab-icon-button
- :active="currentRouteName.match(tab.name)"
- :tab="tab"
- :key="tab.unicode"
- @click="handleIconButtonClick(tab.name)"
- >
- </tab-icon-button>
- </template>
- </div>
- </div>
- </template>
- <script>
- import TabIconButton from '@/components/TabIconButton'
- export default {
- components: { TabIconButton },
- props: ['tabs', 'role'],
- data () {
- return {
- currentRouteName: this.$route.name
- }
- },
- mounted () {
- this.resizeHandler()
- window.addEventListener('resize', this.resizeHandler)
- },
- destroyed () {
- window.removeEventListener('resize', this.resizeHandler)
- },
- watch: {
- $route () {
- this.currentRouteName = this.$route.path
- }
- },
- methods: {
- resizeHandler () {
- if (window.innerWidth < 900) {
- this.componentType = 'full-screen-component'
- } else {
- this.componentType = 'tab-side-component'
- }
- },
- handleIconButtonClick (name) {
- this.$router.push(`/${this.role}/${name}`)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '~@/style/theme.scss';
- .user-home-layout {
- height: 100vh;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .main-container {
- display: flex;
- width: 100%;
- margin: 0 auto;
- justify-content: center;
- }
- // 大屏幕情况
- @media (min-width: 600px) {
- .menu-container-large {
- padding: 24px 18px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- .tab-icon-button {
- margin: 16px 0;
- }
- }
- .tab-container {
- display: flex;
- padding: 24px 18px;
- max-width: 800px;
- }
- .menu-container-small {
- display: none;
- }
- }
- // 小屏幕情况
- @media (max-width: 599px) {
- .menu-container-large {
- display: none;
- }
- .tab-container {
- box-sizing: border-box;
- height: calc(100vh - 54px);
- padding: 48px 24px;
- margin-bottom: 30px;
- width: 100%;
- flex: 1;
- }
- .user-home-layout {
- justify-content: unset;
- min-height: calc(100vh - 54px);
- }
- .menu-container-small {
- z-index: 2;
- backdrop-filter: saturate(180%) blur(15px);
- background: rgba(255, 255, 255, 0.8);
- width: 100%;
- position: fixed;
- padding: 12px 0;
- height: 54px;
- box-sizing: border-box;
- bottom: 0;
- display: flex;
- align-items: center;
- justify-content: space-around;
- }
- .tab {
- min-width: unset;
- padding: unset;
- }
- }
- @supports (not(backdrop-filter: saturate(180%) blur(15px))) {
- .menu-container-small {
- background: rgb(255, 255, 255);
- }
- }
- </style>
|