diff --git a/Web/src/App.vue b/Web/src/App.vue index 6ac5457..7e28ff9 100644 --- a/Web/src/App.vue +++ b/Web/src/App.vue @@ -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) => { diff --git a/Web/src/assets/main.css b/Web/src/assets/main.css index bb1e9cd..1547db8 100644 --- a/Web/src/assets/main.css +++ b/Web/src/assets/main.css @@ -6,10 +6,10 @@ html, body { overscroll-behavior-y: none; -webkit-overflow-scrolling: touch; touch-action: pan-y; - position: fixed; width: 100%; height: 100%; - overflow: hidden; + margin: 0; + padding: 0; } body { @@ -22,12 +22,8 @@ body { max-width: 1280px; margin: 0 auto; font-weight: normal; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - overflow-y: auto; + width: 100%; + height: 100%; overflow-x: hidden; -webkit-overflow-scrolling: touch; } diff --git a/Web/src/styles/common.css b/Web/src/styles/common.css index 4616f53..cdd7f72 100644 --- a/Web/src/styles/common.css +++ b/Web/src/styles/common.css @@ -1,7 +1,8 @@ /* 通用页面容器样式 */ .page-container { - min-height: 100vh; + min-height: var(--vh, 100vh); background-color: #f5f5f5; + padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); } @media (prefers-color-scheme: dark) { @@ -12,7 +13,7 @@ /* 下拉刷新包装器 */ .refresh-wrapper { - min-height: calc(100vh - 46px); + min-height: calc(var(--vh, 100vh) - 46px - 50px - env(safe-area-inset-bottom, 0px)); } /* 增加卡片组的对比度 */ diff --git a/Web/src/views/CalendarView.vue b/Web/src/views/CalendarView.vue index 3600601..18b5f98 100644 --- a/Web/src/views/CalendarView.vue +++ b/Web/src/views/CalendarView.vue @@ -183,13 +183,16 @@ fetchDailyStatistics(now.getFullYear(), now.getMonth() + 1)