|
@@ -1,33 +1,31 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <Teleport to="body">
|
|
|
|
|
- <div v-if="visible" class="footer-wrap">
|
|
|
|
|
- <nav class="footer" :class="{ isWhite }">
|
|
|
|
|
- <div
|
|
|
|
|
- v-for="item in tabs"
|
|
|
|
|
- :key="item.id"
|
|
|
|
|
- class="footer-item"
|
|
|
|
|
- :class="{ active: currentTab === item.id }"
|
|
|
|
|
- @click="refresh(item.id)"
|
|
|
|
|
- >
|
|
|
|
|
- <template v-if="!isRefreshing(item.id)">
|
|
|
|
|
- <div class="icon-placeholder">
|
|
|
|
|
- <img
|
|
|
|
|
- class="icon-img"
|
|
|
|
|
- :src="currentTab === item.id ? item.iconActive : item.icon"
|
|
|
|
|
- :alt="item.label"
|
|
|
|
|
- />
|
|
|
|
|
- </div>
|
|
|
|
|
- <span class="label" :class="{ active: currentTab === item.id }">{{ item.label }}</span>
|
|
|
|
|
- </template>
|
|
|
|
|
- </div>
|
|
|
|
|
- </nav>
|
|
|
|
|
- </div>
|
|
|
|
|
- </Teleport>
|
|
|
|
|
|
|
+ <div v-if="visible" class="footer-wrap">
|
|
|
|
|
+ <nav class="footer" :class="{ isWhite }">
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-for="item in tabs"
|
|
|
|
|
+ :key="item.id"
|
|
|
|
|
+ class="footer-item"
|
|
|
|
|
+ :class="{ active: currentTab === item.id }"
|
|
|
|
|
+ @click="refresh(item.id)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template v-if="!isRefreshing(item.id)">
|
|
|
|
|
+ <div class="icon-placeholder">
|
|
|
|
|
+ <img
|
|
|
|
|
+ class="icon-img"
|
|
|
|
|
+ :src="currentTab === item.id ? item.iconActive : item.icon"
|
|
|
|
|
+ :alt="item.label"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <span class="label" :class="{ active: currentTab === item.id }">{{ item.label }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </nav>
|
|
|
|
|
+ </div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
|
|
-import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
|
|
+import { onMounted, onUnmounted, ref } from 'vue'
|
|
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
import bus, { EVENT_KEY } from '@/utils/bus'
|
|
import bus, { EVENT_KEY } from '@/utils/bus'
|
|
|
import tab1 from '@/assets/img/tabbar/tab-1.png'
|
|
import tab1 from '@/assets/img/tabbar/tab-1.png'
|
|
|
import tabAct1 from '@/assets/img/tabbar/tab-act-1.png'
|
|
import tabAct1 from '@/assets/img/tabbar/tab-act-1.png'
|
|
@@ -42,15 +40,8 @@ const props = defineProps({
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
-const route = useRoute()
|
|
|
|
|
const currentTab = ref(props.initTab)
|
|
const currentTab = ref(props.initTab)
|
|
|
-/** douyin:bus 控制;扩展:仅 footerTab 路由 + 首页子层可隐藏 */
|
|
|
|
|
-const panelVisible = ref(true)
|
|
|
|
|
-const fullscreenHidden = ref(false)
|
|
|
|
|
-const hasFooterTab = computed(() => route.meta.footerTab != null)
|
|
|
|
|
-const visible = computed(
|
|
|
|
|
- () => hasFooterTab.value && panelVisible.value && !fullscreenHidden.value,
|
|
|
|
|
-)
|
|
|
|
|
|
|
+const visible = ref(true)
|
|
|
|
|
|
|
|
const tabs = [
|
|
const tabs = [
|
|
|
{
|
|
{
|
|
@@ -76,16 +67,6 @@ const tabs = [
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-function syncTabFromRoute() {
|
|
|
|
|
- const tab = route.meta.footerTab as number | undefined
|
|
|
|
|
- if (tab) {
|
|
|
|
|
- currentTab.value = tab
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- const item = tabs.find((t) => t.path === route.path)
|
|
|
|
|
- if (item) currentTab.value = item.id
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const isRefresh1 = ref(false)
|
|
const isRefresh1 = ref(false)
|
|
|
const isRefresh2 = ref(false)
|
|
const isRefresh2 = ref(false)
|
|
|
const isRefresh3 = ref(false)
|
|
const isRefresh3 = ref(false)
|
|
@@ -107,7 +88,7 @@ function tab(index: number) {
|
|
|
const item = tabs.find((t) => t.id === index)
|
|
const item = tabs.find((t) => t.id === index)
|
|
|
if (!item) return
|
|
if (!item) return
|
|
|
currentTab.value = index
|
|
currentTab.value = index
|
|
|
- if (route.path !== item.path) {
|
|
|
|
|
|
|
+ if (router.currentRoute.value.path !== item.path) {
|
|
|
router.push(item.path)
|
|
router.push(item.path)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -124,25 +105,15 @@ function refresh(index: number) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-watch(
|
|
|
|
|
- () => route.path,
|
|
|
|
|
- () => {
|
|
|
|
|
- panelVisible.value = true
|
|
|
|
|
- fullscreenHidden.value = false
|
|
|
|
|
- syncTabFromRoute()
|
|
|
|
|
- },
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- syncTabFromRoute()
|
|
|
|
|
bus.on('setFooterVisible', (e) => {
|
|
bus.on('setFooterVisible', (e) => {
|
|
|
- panelVisible.value = e as boolean
|
|
|
|
|
|
|
+ visible.value = e as boolean
|
|
|
})
|
|
})
|
|
|
bus.on(EVENT_KEY.ENTER_FULLSCREEN, () => {
|
|
bus.on(EVENT_KEY.ENTER_FULLSCREEN, () => {
|
|
|
- fullscreenHidden.value = true
|
|
|
|
|
|
|
+ visible.value = false
|
|
|
})
|
|
})
|
|
|
bus.on(EVENT_KEY.EXIT_FULLSCREEN, () => {
|
|
bus.on(EVENT_KEY.EXIT_FULLSCREEN, () => {
|
|
|
- fullscreenHidden.value = false
|
|
|
|
|
|
|
+ visible.value = true
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -155,12 +126,12 @@ onUnmounted(() => {
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
<style scoped lang="less">
|
|
|
.footer-wrap {
|
|
.footer-wrap {
|
|
|
- position: fixed;
|
|
|
|
|
|
|
+ position: absolute;
|
|
|
left: 50%;
|
|
left: 50%;
|
|
|
bottom: var(--footer-bottom-offset, 30rem);
|
|
bottom: var(--footer-bottom-offset, 30rem);
|
|
|
z-index: 10;
|
|
z-index: 10;
|
|
|
transform: translateX(-50%);
|
|
transform: translateX(-50%);
|
|
|
- width: calc(100vw - 32rem);
|
|
|
|
|
|
|
+ width: calc(100% - 32rem);
|
|
|
max-width: 360rem;
|
|
max-width: 360rem;
|
|
|
pointer-events: none;
|
|
pointer-events: none;
|
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|