refactor(utils): 移除未使用的 tabBar 相关代码并简化导入

清理不再使用的 tabBar 相关函数和变量,简化 pages.json 的导入方式
This commit is contained in:
feige996 2025-06-21 13:37:17 +08:00
parent 2a71d02ab8
commit 7b3e757301

View File

@ -1,8 +1,6 @@
import pagesConfig from '@/pages.json'
import { pages, subPackages } from '@/pages.json'
import { isMpWeixin } from './platform'
const { pages, subPackages, tabBar = { list: [] } } = { ...pagesConfig }
export const getLastPage = () => {
// getCurrentPages() 至少有1个元素所以不再额外判断
// const lastPage = getCurrentPages().at(-1)
@ -11,40 +9,6 @@ export const getLastPage = () => {
return pages[pages.length - 1]
}
export const tabBarList = tabBar?.list || []
/** 判断当前页面是否是 tabbar 页 */
export const getIsTabbar = () => {
try {
const lastPage = getLastPage()
const currPath = lastPage?.route
return Boolean(tabBar?.list?.some((item) => item.pagePath === currPath))
} catch {
return false
}
}
/**
* tabbar
* @param path
* @returns true: tabbar false: tabbar
*/
export const isTableBar = (path: string) => {
if (!tabBar) {
return false
}
if (!tabBar.list.length) {
// 通常有 tabBar 的话list 不能有空且至少有2个元素这里其实不用处理
return false
}
// 这里需要处理一下 path因为 tabBar 中的 pagePath 是不带 /pages 前缀的
if (path.startsWith('/')) {
path = path.substring(1)
}
return !!tabBar.list.find((e) => e.pagePath === path)
}
/**
* path redirectPath
* path '/pages/login/index'