feat(utils): 添加判断当前页面是否为tabbar页面的功能

新增isCurrentPageTabbar函数,用于检查当前页面是否属于tabbar配置中的页面
This commit is contained in:
feige996
2025-08-05 20:51:07 +08:00
parent fd469a2552
commit 498ddcd04b

View File

@@ -1,4 +1,5 @@
import { pages, subPackages } from '@/pages.json'
import { tabbarList } from '@/tabbar/config'
import { isMpWeixin } from './platform'
export function getLastPage() {
@@ -9,6 +10,13 @@ export function getLastPage() {
return pages[pages.length - 1]
}
export function isCurrentPageTabbar() {
const lastPage = getLastPage()
const currRoute = (lastPage as any).$page
const { fullPath } = currRoute as { fullPath: string }
return tabbarList.some(item => `/${item.path}` === fullPath)
}
/**
* 获取当前页面路由的 path 路径和 redirectPath 路径
* path 如 '/pages/login/index'