2025-12-25 11:20:56 +08:00
|
|
|
|
<template>
|
2026-01-23 17:14:41 +08:00
|
|
|
|
<van-config-provider
|
|
|
|
|
|
:theme="theme"
|
2026-02-11 14:29:31 +08:00
|
|
|
|
:theme-vars="themeVars"
|
2026-01-23 17:14:41 +08:00
|
|
|
|
class="app-provider"
|
|
|
|
|
|
>
|
2025-12-25 17:12:19 +08:00
|
|
|
|
<div class="app-root">
|
2026-02-02 16:59:24 +08:00
|
|
|
|
<router-view v-slot="{ Component }">
|
|
|
|
|
|
<keep-alive
|
|
|
|
|
|
:include="cachedViews"
|
|
|
|
|
|
:max="8"
|
|
|
|
|
|
>
|
|
|
|
|
|
<component
|
|
|
|
|
|
:is="Component"
|
|
|
|
|
|
:key="route.name"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</keep-alive>
|
|
|
|
|
|
</router-view>
|
2026-01-23 17:14:41 +08:00
|
|
|
|
<van-tabbar
|
|
|
|
|
|
v-show="showTabbar"
|
|
|
|
|
|
v-model="active"
|
2026-02-11 15:19:30 +08:00
|
|
|
|
style="position: fixed !important; bottom: 0 !important; left: 0; right: 0;"
|
2026-01-23 17:14:41 +08:00
|
|
|
|
>
|
|
|
|
|
|
<van-tabbar-item
|
|
|
|
|
|
name="ccalendar"
|
|
|
|
|
|
icon="notes"
|
|
|
|
|
|
to="/calendar"
|
|
|
|
|
|
>
|
|
|
|
|
|
日历
|
|
|
|
|
|
</van-tabbar-item>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-tabbar-item
|
|
|
|
|
|
name="statistics"
|
|
|
|
|
|
icon="chart-trending-o"
|
|
|
|
|
|
to="/"
|
|
|
|
|
|
@click="handleTabClick('/statistics')"
|
|
|
|
|
|
>
|
2025-12-26 15:21:31 +08:00
|
|
|
|
统计
|
|
|
|
|
|
</van-tabbar-item>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-tabbar-item
|
|
|
|
|
|
name="balance"
|
|
|
|
|
|
icon="balance-list"
|
|
|
|
|
|
:to="messageStore.unreadCount > 0 ? '/balance?tab=message' : '/balance'"
|
|
|
|
|
|
:badge="messageStore.unreadCount || null"
|
2026-01-07 14:33:30 +08:00
|
|
|
|
@click="handleTabClick('/balance')"
|
2026-01-06 20:55:11 +08:00
|
|
|
|
>
|
|
|
|
|
|
账单
|
2025-12-25 17:12:19 +08:00
|
|
|
|
</van-tabbar-item>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-tabbar-item
|
|
|
|
|
|
name="budget"
|
|
|
|
|
|
icon="bill-o"
|
|
|
|
|
|
to="/budget"
|
|
|
|
|
|
@click="handleTabClick('/budget')"
|
|
|
|
|
|
>
|
2026-01-06 21:15:02 +08:00
|
|
|
|
预算
|
|
|
|
|
|
</van-tabbar-item>
|
2026-01-23 17:14:41 +08:00
|
|
|
|
<van-tabbar-item
|
|
|
|
|
|
name="setting"
|
|
|
|
|
|
icon="setting"
|
|
|
|
|
|
to="/setting"
|
|
|
|
|
|
>
|
|
|
|
|
|
设置
|
|
|
|
|
|
</van-tabbar-item>
|
2025-12-25 17:12:19 +08:00
|
|
|
|
</van-tabbar>
|
2026-01-23 17:14:41 +08:00
|
|
|
|
<GlobalAddBill
|
|
|
|
|
|
v-if="isShowAddBill"
|
|
|
|
|
|
@success="handleAddTransactionSuccess"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="needRefresh"
|
|
|
|
|
|
class="update-toast"
|
|
|
|
|
|
@click="updateServiceWorker"
|
|
|
|
|
|
>
|
|
|
|
|
|
<van-icon
|
|
|
|
|
|
name="upgrade"
|
|
|
|
|
|
class="update-icon"
|
|
|
|
|
|
/>
|
2026-01-02 18:58:07 +08:00
|
|
|
|
<span>新版本可用,点击刷新</span>
|
|
|
|
|
|
</div>
|
2026-02-11 14:42:46 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 调试信息面板 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="showDebug"
|
|
|
|
|
|
class="debug-panel"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="debug-title">
|
|
|
|
|
|
底部导航栏调试信息
|
|
|
|
|
|
</div>
|
2026-02-11 14:53:49 +08:00
|
|
|
|
<div class="debug-section">
|
|
|
|
|
|
<div class="debug-subtitle">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
TabBar 存在性检查
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
2026-02-11 15:19:30 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="debug-item"
|
|
|
|
|
|
:style="{ color: debugInfo.tabbarExists ? '#81c784' : '#ff4d4f', fontWeight: 'bold' }"
|
|
|
|
|
|
>
|
|
|
|
|
|
TabBar 元素存在: {{ debugInfo.tabbarExists ? '✓ 是' : '✗ 否' }}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
2026-02-11 15:19:30 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="debug-item"
|
|
|
|
|
|
:style="{ color: debugInfo.tabbarVisible ? '#81c784' : '#ff4d4f', fontWeight: 'bold' }"
|
|
|
|
|
|
>
|
|
|
|
|
|
TabBar 可见: {{ debugInfo.tabbarVisible ? '✓ 是' : '✗ 否' }}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
display: {{ debugInfo.tabbarDisplay }}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
opacity: {{ debugInfo.tabbarOpacity }}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-02-11 14:42:46 +08:00
|
|
|
|
<div class="debug-section">
|
|
|
|
|
|
<div class="debug-subtitle">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
TabBar 位置样式
|
2026-02-11 14:42:46 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
position: {{ debugInfo.tabbarPosition }}
|
2026-02-11 14:42:46 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
top (CSS): {{ debugInfo.tabbarTopStyle }}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
bottom (CSS): {{ debugInfo.tabbarBottomStyle }}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
left (实际): {{ debugInfo.tabbarLeft }}px
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
right (实际): {{ debugInfo.tabbarRight }}px
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="debug-item"
|
|
|
|
|
|
:style="{ fontWeight: 'bold', color: '#ff9800' }"
|
|
|
|
|
|
>
|
2026-02-11 14:53:49 +08:00
|
|
|
|
top (实际): {{ debugInfo.tabbarTop }}px
|
|
|
|
|
|
</div>
|
2026-02-11 15:19:30 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="debug-item"
|
|
|
|
|
|
:style="{ fontWeight: 'bold', color: '#ff9800' }"
|
|
|
|
|
|
>
|
2026-02-11 14:53:49 +08:00
|
|
|
|
bottom (实际): {{ debugInfo.tabbarBottom }}px
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-section">
|
|
|
|
|
|
<div class="debug-subtitle">
|
|
|
|
|
|
TabBar 尺寸
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
width: {{ debugInfo.tabbarWidth }}px
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
height: {{ debugInfo.tabbarHeight }}px
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
|
|
|
|
|
padding-bottom: {{ debugInfo.tabbarPaddingBottom }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-item">
|
|
|
|
|
|
box-sizing: {{ debugInfo.tabbarBoxSizing }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="debug-section">
|
|
|
|
|
|
<div class="debug-subtitle">
|
2026-02-11 15:19:30 +08:00
|
|
|
|
结果
|
2026-02-11 14:53:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="debug-item"
|
2026-02-11 15:19:30 +08:00
|
|
|
|
:style="{ color: debugInfo.distanceFromBottom === '0.00' ? '#81c784' : '#ff4d4f', fontWeight: 'bold', fontSize: '12px' }"
|
2026-02-11 14:53:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
距离底部: {{ debugInfo.distanceFromBottom }}px {{ debugInfo.distanceFromBottom === '0.00' ? '✓ 已贴底' : '✗ 未贴底' }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button
|
|
|
|
|
|
class="debug-close"
|
|
|
|
|
|
@click="showDebug = false"
|
|
|
|
|
|
>
|
|
|
|
|
|
关闭
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 视觉调试辅助线 - 标记屏幕底部 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="showDebug"
|
|
|
|
|
|
class="debug-bottom-line"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 视觉调试辅助线 - 标记 TabBar 顶部 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="showDebug"
|
|
|
|
|
|
class="debug-tabbar-top-line"
|
|
|
|
|
|
:style="{ top: debugInfo.tabbarTop + 'px' }"
|
|
|
|
|
|
/>
|
2025-12-25 16:53:56 +08:00
|
|
|
|
</div>
|
2025-12-25 11:20:56 +08:00
|
|
|
|
</van-config-provider>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { RouterView, useRoute } from 'vue-router'
|
2025-12-29 14:18:09 +08:00
|
|
|
|
import { ref, onMounted, onUnmounted, computed, watch } from 'vue'
|
|
|
|
|
|
import { useMessageStore } from '@/stores/message'
|
2026-01-01 14:43:43 +08:00
|
|
|
|
import GlobalAddBill from '@/components/Global/GlobalAddBill.vue'
|
2026-01-02 18:58:07 +08:00
|
|
|
|
import { needRefresh, updateServiceWorker } from './registerServiceWorker'
|
2025-12-26 17:29:17 +08:00
|
|
|
|
import '@/styles/common.css'
|
2025-12-25 11:20:56 +08:00
|
|
|
|
|
2025-12-29 14:18:09 +08:00
|
|
|
|
const messageStore = useMessageStore()
|
2025-12-29 11:30:41 +08:00
|
|
|
|
|
2026-02-02 16:59:24 +08:00
|
|
|
|
// 定义需要缓存的页面组件名称
|
|
|
|
|
|
const cachedViews = ref([
|
|
|
|
|
|
'CalendarV2', // 日历V2页面
|
|
|
|
|
|
'CalendarView', // 日历V1页面
|
|
|
|
|
|
'StatisticsView', // 统计页面
|
2026-02-09 19:25:51 +08:00
|
|
|
|
'StatisticsV2View', // 统计V2页面
|
2026-02-02 16:59:24 +08:00
|
|
|
|
'BalanceView', // 账单页面
|
|
|
|
|
|
'BudgetView' // 预算页面
|
|
|
|
|
|
])
|
|
|
|
|
|
|
2025-12-25 17:30:29 +08:00
|
|
|
|
const updateVh = () => {
|
2025-12-25 17:20:50 +08:00
|
|
|
|
const vh = window.innerHeight
|
|
|
|
|
|
document.documentElement.style.setProperty('--vh', `${vh}px`)
|
2025-12-25 16:53:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-08 15:23:31 +08:00
|
|
|
|
// 修复 PWA 模式下键盘收起页面不回弹的问题
|
|
|
|
|
|
const handleFocusOut = () => {
|
|
|
|
|
|
if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
|
|
|
|
|
|
// 延迟一小段时间执行,确保键盘收起动作已开始
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
// 强制回到顶部
|
|
|
|
|
|
window.scrollTo(0, 0)
|
|
|
|
|
|
// 同时也触发一次高度更新
|
|
|
|
|
|
updateVh()
|
|
|
|
|
|
}, 100)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-25 16:53:56 +08:00
|
|
|
|
onMounted(() => {
|
2025-12-25 17:30:29 +08:00
|
|
|
|
updateVh()
|
|
|
|
|
|
window.addEventListener('resize', updateVh)
|
2025-12-25 17:20:50 +08:00
|
|
|
|
if (window.visualViewport) {
|
2025-12-25 17:30:29 +08:00
|
|
|
|
window.visualViewport.addEventListener('resize', updateVh)
|
2025-12-25 17:20:50 +08:00
|
|
|
|
}
|
2026-01-08 15:23:31 +08:00
|
|
|
|
// 注册全局失去焦点监听
|
|
|
|
|
|
document.addEventListener('focusout', handleFocusOut)
|
2025-12-25 16:53:56 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
2025-12-25 17:30:29 +08:00
|
|
|
|
window.removeEventListener('resize', updateVh)
|
2025-12-25 17:20:50 +08:00
|
|
|
|
if (window.visualViewport) {
|
2025-12-25 17:30:29 +08:00
|
|
|
|
window.visualViewport.removeEventListener('resize', updateVh)
|
2025-12-25 17:20:50 +08:00
|
|
|
|
}
|
2026-01-08 15:23:31 +08:00
|
|
|
|
// 销毁监听
|
|
|
|
|
|
document.removeEventListener('focusout', handleFocusOut)
|
2025-12-25 16:53:56 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-25 16:44:34 +08:00
|
|
|
|
const route = useRoute()
|
2025-12-25 13:27:23 +08:00
|
|
|
|
// 根据路由判断是否显示Tabbar
|
|
|
|
|
|
const showTabbar = computed(() => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
return (
|
|
|
|
|
|
route.path === '/' ||
|
2025-12-25 16:37:09 +08:00
|
|
|
|
route.path === '/calendar' ||
|
2026-02-02 16:59:24 +08:00
|
|
|
|
route.path === '/calendar-v2' ||
|
2025-12-28 10:23:57 +08:00
|
|
|
|
route.path === '/message' ||
|
2025-12-26 15:21:31 +08:00
|
|
|
|
route.path === '/setting' ||
|
2026-01-06 20:55:11 +08:00
|
|
|
|
route.path === '/balance' ||
|
|
|
|
|
|
route.path === '/budget'
|
2026-01-16 11:15:44 +08:00
|
|
|
|
)
|
2025-12-25 13:27:23 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-27 11:50:12 +08:00
|
|
|
|
const active = ref('')
|
2025-12-25 11:20:56 +08:00
|
|
|
|
const theme = ref('light')
|
|
|
|
|
|
|
2026-02-11 14:29:31 +08:00
|
|
|
|
// Vant UI 主题变量映射
|
|
|
|
|
|
const themeVars = computed(() => {
|
|
|
|
|
|
const vars = {
|
|
|
|
|
|
navBarBackground: 'var(--bg-primary)',
|
|
|
|
|
|
navBarTextColor: 'var(--text-primary)',
|
|
|
|
|
|
cardBackground: 'var(--bg-secondary)',
|
|
|
|
|
|
cellBackground: 'var(--bg-secondary)',
|
|
|
|
|
|
background: 'var(--bg-primary)',
|
|
|
|
|
|
background2: 'var(--bg-secondary)',
|
|
|
|
|
|
textColor: 'var(--text-primary)',
|
|
|
|
|
|
textColor2: 'var(--text-secondary)',
|
|
|
|
|
|
borderColor: 'var(--bg-tertiary)',
|
|
|
|
|
|
tabbarBackground: 'var(--bg-primary)'
|
|
|
|
|
|
}
|
|
|
|
|
|
return vars
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-25 11:20:56 +08:00
|
|
|
|
// 检测系统深色模式
|
|
|
|
|
|
const updateTheme = () => {
|
|
|
|
|
|
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
|
|
|
|
theme.value = isDark ? 'dark' : 'light'
|
2026-02-02 16:59:24 +08:00
|
|
|
|
// 在文档根元素上设置 data-theme 属性,使 CSS 变量生效
|
|
|
|
|
|
document.documentElement.setAttribute('data-theme', theme.value)
|
2025-12-25 11:20:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 监听系统主题变化
|
|
|
|
|
|
let mediaQuery
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
updateTheme()
|
|
|
|
|
|
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
|
|
|
|
|
|
mediaQuery.addEventListener('change', updateTheme)
|
2025-12-27 11:50:12 +08:00
|
|
|
|
setActive(route.path)
|
2025-12-25 11:20:56 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-02 12:25:44 +08:00
|
|
|
|
setInterval(() => {
|
|
|
|
|
|
messageStore.updateUnreadCount()
|
2026-01-10 23:01:02 +08:00
|
|
|
|
}, 60 * 1000) // 每60秒更新一次未读消息数
|
2026-01-02 12:25:44 +08:00
|
|
|
|
|
2025-12-27 11:50:12 +08:00
|
|
|
|
// 监听路由变化调整
|
2026-01-16 11:15:44 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => route.path,
|
|
|
|
|
|
(newPath) => {
|
|
|
|
|
|
setActive(newPath)
|
2026-01-10 23:01:02 +08:00
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
messageStore.updateUnreadCount()
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2025-12-27 11:50:12 +08:00
|
|
|
|
|
|
|
|
|
|
const setActive = (path) => {
|
|
|
|
|
|
active.value = (() => {
|
|
|
|
|
|
switch (path) {
|
|
|
|
|
|
case '/calendar':
|
2026-02-02 16:59:24 +08:00
|
|
|
|
case '/calendar-v2':
|
2025-12-27 11:50:12 +08:00
|
|
|
|
return 'ccalendar'
|
2025-12-28 10:23:57 +08:00
|
|
|
|
case '/balance':
|
|
|
|
|
|
case '/message':
|
2026-01-06 20:55:11 +08:00
|
|
|
|
return 'balance'
|
2025-12-27 11:50:12 +08:00
|
|
|
|
case '/setting':
|
|
|
|
|
|
return 'setting'
|
2026-01-06 20:55:11 +08:00
|
|
|
|
case '/budget':
|
|
|
|
|
|
return 'budget'
|
2025-12-27 11:50:12 +08:00
|
|
|
|
default:
|
2025-12-28 10:23:57 +08:00
|
|
|
|
return 'statistics'
|
2025-12-27 11:50:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
})()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-03 11:26:50 +08:00
|
|
|
|
const isShowAddBill = computed(() => {
|
2026-02-02 16:59:24 +08:00
|
|
|
|
return route.path === '/' || route.path === '/balance' || route.path === '/message' || route.path === '/calendar' || route.path === '/calendar-v2'
|
2026-01-03 11:26:50 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-25 11:20:56 +08:00
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
|
if (mediaQuery) {
|
|
|
|
|
|
mediaQuery.removeEventListener('change', updateTheme)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 处理tab点击,如果点击当前页面则滚动到顶部
|
|
|
|
|
|
const handleTabClick = (path) => {
|
|
|
|
|
|
if (route.path === path) {
|
|
|
|
|
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-01 14:43:43 +08:00
|
|
|
|
const handleAddTransactionSuccess = () => {
|
|
|
|
|
|
// 当添加交易成功时,通知当前页面刷新数据
|
|
|
|
|
|
const event = new Event('transactions-changed')
|
|
|
|
|
|
window.dispatchEvent(event)
|
|
|
|
|
|
}
|
2026-02-11 14:42:46 +08:00
|
|
|
|
|
|
|
|
|
|
// 调试信息
|
|
|
|
|
|
const showDebug = ref(true) // 默认显示调试面板
|
|
|
|
|
|
const debugInfo = ref({
|
|
|
|
|
|
windowHeight: 0,
|
|
|
|
|
|
viewportHeight: 0,
|
|
|
|
|
|
safeAreaBottom: '0',
|
2026-02-11 15:19:30 +08:00
|
|
|
|
tabbarExists: false,
|
|
|
|
|
|
tabbarVisible: false,
|
2026-02-11 14:42:46 +08:00
|
|
|
|
tabbarHeight: 0,
|
2026-02-11 15:19:30 +08:00
|
|
|
|
tabbarWidth: 0,
|
2026-02-11 14:42:46 +08:00
|
|
|
|
tabbarBottom: 0,
|
|
|
|
|
|
tabbarTop: 0,
|
2026-02-11 15:19:30 +08:00
|
|
|
|
tabbarLeft: 0,
|
|
|
|
|
|
tabbarRight: 0,
|
2026-02-11 14:42:46 +08:00
|
|
|
|
tabbarPaddingBottom: '0',
|
|
|
|
|
|
tabbarPosition: '',
|
|
|
|
|
|
tabbarBottomStyle: '',
|
2026-02-11 15:19:30 +08:00
|
|
|
|
tabbarTopStyle: '',
|
2026-02-11 14:42:46 +08:00
|
|
|
|
tabbarMinHeight: '',
|
|
|
|
|
|
tabbarBoxSizing: '',
|
2026-02-11 15:19:30 +08:00
|
|
|
|
tabbarDisplay: '',
|
|
|
|
|
|
tabbarOpacity: '',
|
2026-02-11 14:53:49 +08:00
|
|
|
|
appRootHeight: 0,
|
|
|
|
|
|
appRootBottom: 0,
|
|
|
|
|
|
bodyHeight: 0,
|
|
|
|
|
|
htmlHeight: 0,
|
|
|
|
|
|
tabbarTransform: '',
|
|
|
|
|
|
tabbarZIndex: '',
|
|
|
|
|
|
distanceFromBottom: 0
|
2026-02-11 14:42:46 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 更新调试信息
|
|
|
|
|
|
const updateDebugInfo = () => {
|
|
|
|
|
|
debugInfo.value.windowHeight = window.innerHeight
|
|
|
|
|
|
debugInfo.value.viewportHeight = window.visualViewport?.height || window.innerHeight
|
|
|
|
|
|
|
|
|
|
|
|
// 获取安全区域底部值
|
|
|
|
|
|
const testDiv = document.createElement('div')
|
|
|
|
|
|
testDiv.style.paddingBottom = 'env(safe-area-inset-bottom, 0px)'
|
|
|
|
|
|
document.body.appendChild(testDiv)
|
|
|
|
|
|
const computed = window.getComputedStyle(testDiv)
|
|
|
|
|
|
debugInfo.value.safeAreaBottom = computed.paddingBottom
|
|
|
|
|
|
document.body.removeChild(testDiv)
|
|
|
|
|
|
|
|
|
|
|
|
// 获取 TabBar 的实际尺寸和位置
|
|
|
|
|
|
const tabbar = document.querySelector('.van-tabbar')
|
2026-02-11 15:19:30 +08:00
|
|
|
|
debugInfo.value.tabbarExists = !!tabbar
|
|
|
|
|
|
debugInfo.value.tabbarVisible = tabbar ? window.getComputedStyle(tabbar).display !== 'none' : false
|
|
|
|
|
|
|
2026-02-11 14:42:46 +08:00
|
|
|
|
if (tabbar) {
|
|
|
|
|
|
const rect = tabbar.getBoundingClientRect()
|
|
|
|
|
|
const styles = window.getComputedStyle(tabbar)
|
|
|
|
|
|
debugInfo.value.tabbarHeight = rect.height.toFixed(2)
|
2026-02-11 15:19:30 +08:00
|
|
|
|
debugInfo.value.tabbarWidth = rect.width.toFixed(2)
|
2026-02-11 14:42:46 +08:00
|
|
|
|
debugInfo.value.tabbarBottom = rect.bottom.toFixed(2)
|
|
|
|
|
|
debugInfo.value.tabbarPaddingBottom = styles.paddingBottom
|
|
|
|
|
|
debugInfo.value.tabbarTop = rect.top.toFixed(2)
|
2026-02-11 15:19:30 +08:00
|
|
|
|
debugInfo.value.tabbarLeft = rect.left.toFixed(2)
|
|
|
|
|
|
debugInfo.value.tabbarRight = rect.right.toFixed(2)
|
2026-02-11 14:42:46 +08:00
|
|
|
|
debugInfo.value.tabbarPosition = styles.position
|
|
|
|
|
|
debugInfo.value.tabbarBottomStyle = styles.bottom
|
2026-02-11 15:19:30 +08:00
|
|
|
|
debugInfo.value.tabbarTopStyle = styles.top
|
2026-02-11 14:42:46 +08:00
|
|
|
|
debugInfo.value.tabbarMinHeight = styles.minHeight
|
|
|
|
|
|
debugInfo.value.tabbarBoxSizing = styles.boxSizing
|
2026-02-11 15:19:30 +08:00
|
|
|
|
debugInfo.value.tabbarDisplay = styles.display
|
|
|
|
|
|
debugInfo.value.tabbarOpacity = styles.opacity
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有 transform 或其他可能影响定位的样式
|
|
|
|
|
|
debugInfo.value.tabbarTransform = styles.transform
|
|
|
|
|
|
debugInfo.value.tabbarZIndex = styles.zIndex
|
2026-02-11 14:42:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取 app-root 的高度
|
|
|
|
|
|
const appRoot = document.querySelector('.app-root')
|
|
|
|
|
|
if (appRoot) {
|
|
|
|
|
|
const rect = appRoot.getBoundingClientRect()
|
|
|
|
|
|
debugInfo.value.appRootHeight = rect.height.toFixed(2)
|
2026-02-11 14:53:49 +08:00
|
|
|
|
debugInfo.value.appRootBottom = rect.bottom.toFixed(2)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取 body 和 html 的高度
|
|
|
|
|
|
debugInfo.value.bodyHeight = document.body.getBoundingClientRect().height.toFixed(2)
|
|
|
|
|
|
debugInfo.value.htmlHeight = document.documentElement.getBoundingClientRect().height.toFixed(2)
|
|
|
|
|
|
|
|
|
|
|
|
// 计算 TabBar 距离屏幕底部的实际距离
|
2026-02-11 15:19:30 +08:00
|
|
|
|
debugInfo.value.distanceFromBottom = (window.innerHeight - parseFloat(debugInfo.value.tabbarBottom || 0)).toFixed(2)
|
2026-02-11 14:42:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
// 延迟获取调试信息,确保 DOM 已渲染
|
|
|
|
|
|
setTimeout(updateDebugInfo, 500)
|
|
|
|
|
|
// 每秒更新一次调试信息
|
|
|
|
|
|
const debugInterval = setInterval(updateDebugInfo, 1000)
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
|
clearInterval(debugInterval)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2025-12-25 11:20:56 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2025-12-25 14:15:43 +08:00
|
|
|
|
<style scoped>
|
2025-12-25 17:12:19 +08:00
|
|
|
|
.app-provider {
|
2025-12-25 17:20:50 +08:00
|
|
|
|
/* 使用准确的视口高度 CSS 变量 */
|
|
|
|
|
|
height: var(--vh, 100vh);
|
|
|
|
|
|
width: 100%;
|
2026-02-04 16:23:12 +08:00
|
|
|
|
background-color: var(--van-background);
|
2025-12-25 17:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-25 16:53:56 +08:00
|
|
|
|
.app-root {
|
|
|
|
|
|
height: 100%;
|
2025-12-25 17:20:50 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
position: relative;
|
2025-12-29 11:14:29 +08:00
|
|
|
|
padding-top: max(0px, calc(env(safe-area-inset-top, 0px) * 0.75));
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
overflow: hidden;
|
2026-02-04 16:23:12 +08:00
|
|
|
|
background-color: var(--van-background);
|
2025-12-25 17:20:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* TabBar 固定在底部 */
|
|
|
|
|
|
:deep(.van-tabbar) {
|
2025-12-25 17:28:06 +08:00
|
|
|
|
position: fixed !important;
|
|
|
|
|
|
bottom: 0 !important;
|
2025-12-25 17:20:50 +08:00
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
2025-12-25 17:28:06 +08:00
|
|
|
|
/* 重置所有 padding,然后只添加安全区域 */
|
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
|
padding-bottom: env(safe-area-inset-bottom, 0px) !important;
|
2026-02-11 14:47:53 +08:00
|
|
|
|
height: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
|
|
|
|
|
|
box-sizing: border-box !important;
|
2026-02-11 14:29:31 +08:00
|
|
|
|
background: var(--bg-primary) !important;
|
|
|
|
|
|
border-top: 1px solid var(--bg-tertiary);
|
2025-12-25 17:28:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 确保 TabBar 项目居中 */
|
|
|
|
|
|
:deep(.van-tabbar-item) {
|
|
|
|
|
|
padding: 0 !important;
|
2025-12-29 11:23:33 +08:00
|
|
|
|
height: 50px !important;
|
2026-02-11 14:29:31 +08:00
|
|
|
|
color: var(--text-secondary);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.van-tabbar-item--active) {
|
|
|
|
|
|
color: var(--color-primary);
|
2025-12-25 16:53:56 +08:00
|
|
|
|
}
|
2025-12-29 11:30:41 +08:00
|
|
|
|
|
|
|
|
|
|
.debug-overlay {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
z-index: 9999;
|
|
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
pointer-events: auto;
|
|
|
|
|
|
}
|
2026-01-02 18:58:07 +08:00
|
|
|
|
|
|
|
|
|
|
.update-toast {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
bottom: 80px;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
background-color: var(--van-primary-color);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 10px 20px;
|
|
|
|
|
|
border-radius: 24px;
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
|
|
|
|
z-index: 2000;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.update-toast:active {
|
|
|
|
|
|
transform: translateX(-50%) scale(0.95);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.update-icon {
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
}
|
2026-02-11 14:42:46 +08:00
|
|
|
|
|
|
|
|
|
|
/* 调试面板样式 */
|
|
|
|
|
|
.debug-panel {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
right: 10px;
|
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
|
background: rgba(0, 0, 0, 0.9);
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
z-index: 9999;
|
|
|
|
|
|
min-width: 240px;
|
|
|
|
|
|
max-height: 80vh;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
|
|
|
|
font-family: 'Courier New', monospace;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.debug-title {
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
border-bottom: 2px solid rgba(255, 255, 255, 0.5);
|
|
|
|
|
|
padding-bottom: 6px;
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
color: #4fc3f7;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.debug-section {
|
|
|
|
|
|
margin: 8px 0;
|
|
|
|
|
|
padding: 6px;
|
|
|
|
|
|
background: rgba(255, 255, 255, 0.05);
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
border-left: 3px solid #4fc3f7;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.debug-subtitle {
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
color: #81c784;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.debug-item {
|
|
|
|
|
|
margin: 3px 0;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
padding-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.debug-close {
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
padding: 6px 12px;
|
|
|
|
|
|
background: linear-gradient(135deg, #ff4d4f, #ff7875);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
box-shadow: 0 2px 4px rgba(255, 77, 79, 0.3);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.debug-close:active {
|
|
|
|
|
|
opacity: 0.8;
|
|
|
|
|
|
transform: scale(0.98);
|
|
|
|
|
|
}
|
2026-02-11 14:53:49 +08:00
|
|
|
|
|
|
|
|
|
|
/* 调试辅助线 - 屏幕底部红线 */
|
|
|
|
|
|
.debug-bottom-line {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
height: 2px;
|
|
|
|
|
|
background: red;
|
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 调试辅助线 - TabBar 顶部蓝线 */
|
|
|
|
|
|
.debug-tabbar-top-line {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
height: 2px;
|
|
|
|
|
|
background: blue;
|
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
}
|
2025-12-25 14:15:43 +08:00
|
|
|
|
</style>
|