debugger
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 14s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s

This commit is contained in:
孙诚
2025-12-25 17:20:50 +08:00
parent f42163ed95
commit 239d9dcae3
8 changed files with 47 additions and 20 deletions

View File

@@ -33,6 +33,12 @@ import { ref, onMounted, onUnmounted, computed } from 'vue'
const log = ref('')
const updateInfo = () => {
// 获取真实的视口高度PWA 模式下准确)
const vh = window.innerHeight
// 设置 CSS 变量,让所有组件使用准确的视口高度
document.documentElement.style.setProperty('--vh', `${vh}px`)
document.documentElement.style.setProperty('--vh-offset', `${vh}px`)
log.value = JSON.stringify({
innerHeight: window.innerHeight,
outerHeight: window.outerHeight,
@@ -43,16 +49,24 @@ const updateInfo = () => {
offsetTop: window.visualViewport.offsetTop,
}
: null,
cssVarVh: getComputedStyle(document.documentElement).getPropertyValue('--vh'),
}, null, 2)
}
onMounted(() => {
updateInfo()
window.addEventListener('resize', updateInfo)
// 监听 iOS Safari 视口变化
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', updateInfo)
}
})
onUnmounted(() => {
window.removeEventListener('resize', updateInfo)
if (window.visualViewport) {
window.visualViewport.removeEventListener('resize', updateInfo)
}
})
const route = useRoute()
@@ -98,14 +112,27 @@ const handleTabClick = (path) => {
<style scoped>
.app-provider {
/* 关键:让 config-provider 本身先占满视口 */
height: 100%;
/* 使用准确的视口高度 CSS 变量 */
height: var(--vh, 100vh);
width: 100%;
}
.app-root {
height: 100%;
width: 100%;
position: relative;
border: 2px solid red; /* 调试用红框 */
display: flex;
flex-direction: column;
}
/* TabBar 固定在底部 */
:deep(.van-tabbar) {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding-bottom: 0 !important;
/* 移除可能的安全区域内边距 */
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
</style>