tabbar适配安卓端
This commit is contained in:
+57
-51
@@ -3,75 +3,81 @@
|
||||
<GlobalLoading />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GlobalLoading from '@/components/global/GlobalLoading.vue'
|
||||
import GlobalLoading from '@/components/global/GlobalLoading.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GlobalLoading
|
||||
},
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
this.preloadTabData()
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
// #ifdef APP-PLUS
|
||||
this.hideNativeTabBar()
|
||||
// #endif
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
},
|
||||
methods: {
|
||||
// 隐藏原生 TabBar - 这里是核心修复
|
||||
hideNativeTabBar() {
|
||||
// 尝试多次执行,确保执行成功
|
||||
const tryHide = (times = 0) => {
|
||||
if (times > 10) return // 最多尝试10次
|
||||
|
||||
uni.hideTabBar({
|
||||
animation: false,
|
||||
success: () => {
|
||||
console.log('✅ 原生TabBar隐藏成功')
|
||||
// 强制 CSS 覆盖(双重保险)
|
||||
this.forceCSSHide()
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(`❌ 第${times+1}次隐藏失败,1秒后重试`, err)
|
||||
setTimeout(() => tryHide(times + 1), 1000)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 延迟 300ms 执行,确保页面挂载完成
|
||||
setTimeout(() => tryHide(), 300)
|
||||
},
|
||||
|
||||
// 强制 CSS 覆盖(最终保险)
|
||||
forceCSSHide() {
|
||||
// #ifdef APP-PLUS
|
||||
const style = document.createElement('style')
|
||||
style.innerHTML = `
|
||||
uni-tabbar,
|
||||
uni-tabbar .uni-tabbar,
|
||||
.uni-tabbar,
|
||||
uni-tabbar > .uni-tabbar,
|
||||
[class*="uni-tabbar"] {
|
||||
display: none !important;
|
||||
height: 0 !important;
|
||||
opacity: 0 !important;
|
||||
visibility: hidden !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
`
|
||||
document.head.appendChild(style)
|
||||
console.log('✅ CSS 强制覆盖已注入')
|
||||
// #endif
|
||||
},
|
||||
|
||||
// 预加载所有 Tab 页面的核心数据
|
||||
preloadTabData() {
|
||||
// 延迟执行,不阻塞首屏
|
||||
setTimeout(() => {
|
||||
// 预加载课程数据
|
||||
// #ifdef MP-WEIXIN
|
||||
// 小程序端预请求数据
|
||||
// #endif
|
||||
|
||||
// 预加载训练数据
|
||||
|
||||
// 预加载课程数据等...
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import 'common/style/base.css';
|
||||
|
||||
/* 全局骨架屏样式 */
|
||||
.skeleton {
|
||||
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
@keyframes skeleton-loading {
|
||||
0% { background-position: 200% 0; }
|
||||
100% { background-position: -200% 0; }
|
||||
}
|
||||
|
||||
/* 页面切换动画 */
|
||||
.page-enter-active,
|
||||
.page-leave-active {
|
||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
.page-enter-from {
|
||||
opacity: 0;
|
||||
transform: translateX(30rpx);
|
||||
}
|
||||
|
||||
.page-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(-30rpx);
|
||||
}
|
||||
|
||||
.app-container {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
max-width: 430px;
|
||||
margin: 0 auto;
|
||||
background-color: var(--bg-light);
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
</style>
|
||||
</script>
|
||||
Reference in New Issue
Block a user