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

@ -16,6 +16,7 @@ export default defineUniPages({
'z-paging/components/z-paging$1/z-paging$1.vue',
},
},
// 如果不需要tabBar可以注释掉这个配置或者直接删除
tabBar: {
color: '#999999',
selectedColor: '#018d71',

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)
}
/**