feat: 支持无tabbar

This commit is contained in:
feige996
2025-05-19 15:53:15 +08:00
parent 2975fcec92
commit 1baec3728f
2 changed files with 10 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
import { pages, subPackages, tabBar } from '@/pages.json'
import pagesConfig from '@/pages.json'
import { isMpWeixin } from './platform'
const { pages, subPackages, tabBar = { list: [] } } = { ...pagesConfig }
export const getLastPage = () => {
// getCurrentPages() 至少有1个元素所以不再额外判断
// const lastPage = getCurrentPages().at(-1)
@@ -11,16 +13,14 @@ export const getLastPage = () => {
/** 判断当前页面是否是 tabbar 页 */
export const getIsTabbar = () => {
if (!tabBar) {
try {
const lastPage = getLastPage()
const currPath = lastPage?.route
return Boolean(tabBar?.list?.some((item) => item.pagePath === currPath))
} catch {
return false
}
if (!tabBar.list.length) {
// 通常有 tabBar 的话list 不能有空且至少有2个元素这里其实不用处理
return false
}
const lastPage = getLastPage()
const currPath = lastPage.route
return !!tabBar.list.find((e) => e.pagePath === currPath)
}
/**