feat: frosted floating tab bar and updated icon colors

This commit is contained in:
2026-08-07 15:36:17 +08:00
parent 0762e7bb3d
commit 5db761c73e
14 changed files with 36 additions and 32 deletions
+6 -3
View File
@@ -21,7 +21,8 @@ function matchTab(path: string): string {
}
function currentTabPath(): string {
const path = Taro.getCurrentInstance().router?.path || 'pages/index/index'
const router = Taro.getCurrentInstance().router
const path = router && router.path ? router.path : 'pages/index/index'
return matchTab(path)
}
@@ -42,7 +43,9 @@ export default function CustomTabBar() {
// 其它入口(如页面内部调用 switchTab)也会回到 tabBar,收到事件后重新同步选中态
useEffect(() => {
const handler = (path?: string) => {
setActiveTab(matchTab(path || Taro.getCurrentInstance().router?.path || 'pages/index/index'))
const router = Taro.getCurrentInstance().router
const currentPath = router && router.path ? router.path : 'pages/index/index'
setActiveTab(matchTab(path || currentPath))
}
Taro.eventCenter.on('tabBarChange', handler)
return () => {
@@ -59,7 +62,7 @@ export default function CustomTabBar() {
const switchTab = (url: string) => {
setActiveTab(matchTab(url))
Taro.switchTab({ url })
Taro.eventCenter?.trigger('tabBarChange', url)
Taro.eventCenter.trigger('tabBarChange', url)
}
return (