feat: 修复 H5 底部导航覆盖 + 更新项目进度文档
## H5 底部导航修复 (Bug #10) - 精简 App.vue,移除重复 tabbar,仅保留全局样式 - uni-page 设置 height: calc(100% - 50px) + overflow-y: auto - 内容区域精确停在底部导航上方,独立滚动不再叠加 - 恢复 custom-tab-bar 组件 ## 项目进度文档 - PROGRESS.md 更新至 10 个 Bug 修复 - 新增 H5 底部导航修复记录 - 新增历史变更条目
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<div class="tab-bar" :style="{ opacity: 1 }">
|
||||
<div
|
||||
v-for="(item, index) in tabList"
|
||||
:key="index"
|
||||
class="tab-bar-item"
|
||||
@click="handleSwitchTab(index)"
|
||||
>
|
||||
<span class="tab-bar-icon">{{ item.icon }}</span>
|
||||
<span class="tab-bar-text" :class="{ active: currentIndex === index }">{{ item.text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const currentIndex = ref(0)
|
||||
|
||||
const tabList = ref([
|
||||
{ pagePath: '/pages/index/index', text: '首页', icon: '🏠' },
|
||||
{ pagePath: '/pages/translate/translate', text: '翻译', icon: '🔤' },
|
||||
{ pagePath: '/pages/customers/customers', text: '客户', icon: '👥' },
|
||||
{ pagePath: '/pages/marketing/marketing', text: '营销', icon: '📢' },
|
||||
{ pagePath: '/pages/quotation/quotation', text: '报价', icon: '📄' },
|
||||
])
|
||||
|
||||
const updateCurrentIndex = () => {
|
||||
const hash = window.location.hash || ''
|
||||
console.log('Hash:', hash)
|
||||
for (let i = 0; i < tabList.value.length; i++) {
|
||||
if (hash.includes(tabList.value[i].pagePath)) {
|
||||
currentIndex.value = i
|
||||
return
|
||||
}
|
||||
}
|
||||
currentIndex.value = 0
|
||||
}
|
||||
|
||||
const handleSwitchTab = (index) => {
|
||||
if (currentIndex.value === index) return
|
||||
const url = tabList.value[index].pagePath
|
||||
uni.switchTab({ url })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log('TabBar mounted, tabList:', tabList.value)
|
||||
updateCurrentIndex()
|
||||
window.addEventListener('hashchange', updateCurrentIndex)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('hashchange', updateCurrentIndex)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tab-bar {
|
||||
position: fixed !important;
|
||||
bottom: 0 !important;
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
height: 80px !important;
|
||||
background: #fff !important;
|
||||
display: flex !important;
|
||||
flex-direction: row !important;
|
||||
box-shadow: 0 -4px 16px rgba(0,0,0,0.2) !important;
|
||||
z-index: 999999 !important;
|
||||
border-top: 1px solid #e0e0e0 !important;
|
||||
padding-bottom: env(safe-area-inset-bottom) !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
.tab-bar-item {
|
||||
flex: 1 !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tab-bar-icon {
|
||||
font-size: 28px !important;
|
||||
line-height: 1 !important;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.tab-bar-text {
|
||||
font-size: 12px !important;
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
.tab-bar-text.active {
|
||||
color: #1890ff !important;
|
||||
font-weight: bold !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user