This commit is contained in:
SunCheng
2026-02-15 10:10:28 +08:00
parent e51a3edd50
commit a88556c784
92 changed files with 6751 additions and 776 deletions

View File

@@ -42,7 +42,7 @@ const props = defineProps({
default () {
return [
{ name: 'calendar', label: '日历', icon: 'notes', path: '/calendar-v2' },
{ name: 'statistics', label: '统计', icon: 'chart-trending-o', path: '/' },
{ name: 'statistics', label: '统计', icon: 'chart-trending-o', path: '/statistics-v2' },
{ name: 'balance', label: '账单', icon: 'balance-list', path: '/balance' },
{ name: 'budget', label: '预算', icon: 'bill-o', path: '/budget-v2' },
{ name: 'setting', label: '设置', icon: 'setting', path: '/setting' }
@@ -84,8 +84,10 @@ const getActiveTabFromRoute = (currentPath) => {
// 规范化路径: 去掉 -v2 后缀以支持版本切换
const normalizedPath = currentPath.replace(/-v2$/, '')
const matchedItem = navItems.value.find(item => {
if (!item.path) {return false}
const matchedItem = navItems.value.find((item) => {
if (!item.path) {
return false
}
// 完全匹配
if (item.path === currentPath || item.path === normalizedPath) {
@@ -112,15 +114,23 @@ const updateActiveTab = (newTab) => {
}
// 监听外部 modelValue 的变化
watch(() => props.modelValue, (newValue) => {
updateActiveTab(newValue)
}, { immediate: true })
watch(
() => props.modelValue,
(newValue) => {
updateActiveTab(newValue)
},
{ immediate: true }
)
// 监听路由变化,自动同步底部导航高亮状态
watch(() => route.path, (newPath) => {
const matchedTab = getActiveTabFromRoute(newPath)
updateActiveTab(matchedTab)
}, { immediate: true })
watch(
() => route.path,
(newPath) => {
const matchedTab = getActiveTabFromRoute(newPath)
updateActiveTab(matchedTab)
},
{ immediate: true }
)
const handleTabClick = (item, index) => {
activeTab.value = item.name
@@ -129,7 +139,7 @@ const handleTabClick = (item, index) => {
// 如果有路径定义,则进行路由跳转
if (item.path) {
router.push(item.path).catch(err => {
router.push(item.path).catch((err) => {
// 忽略相同路由导航错误
if (err.name !== 'NavigationDuplicated') {
console.warn('Navigation error:', err)
@@ -195,7 +205,9 @@ onMounted(() => {
display: flex;
align-items: center;
justify-content: space-around;
box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
box-shadow:
0 -4px 24px rgba(0, 0, 0, 0.08),
0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
pointer-events: auto;
}
@@ -218,17 +230,21 @@ onMounted(() => {
/* 亮色模式文字颜色(默认) */
.nav-label {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
font-family:
'Inter',
-apple-system,
BlinkMacSystemFont,
sans-serif;
font-size: 10px;
font-weight: 500;
color: #9CA3AF;
color: #9ca3af;
transition: all 0.2s ease;
line-height: 1.2;
}
.nav-label-active {
font-weight: 600;
color: #1A1A1A;
color: #1a1a1a;
}
/* 响应式适配 */
@@ -254,15 +270,17 @@ onMounted(() => {
backdrop-filter: blur(40px) saturate(180%);
-webkit-backdrop-filter: blur(40px) saturate(180%);
border-color: rgba(42, 42, 46, 0.6);
box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(255, 255, 255, 0.1) inset;
box-shadow:
0 -4px 24px rgba(0, 0, 0, 0.25),
0 0 0 0.5px rgba(255, 255, 255, 0.1) inset;
}
.nav-label {
color: #6B6B6F;
color: #6b6b6f;
}
.nav-label-active {
color: #FAFAF9;
color: #fafaf9;
}
}
@@ -302,4 +320,4 @@ onMounted(() => {
}
}
}
</style>
</style>