refactor(utils): 移除未使用的 tabBar 相关代码并简化导入
清理不再使用的 tabBar 相关函数和变量,简化 pages.json 的导入方式
This commit is contained in:
parent
2a71d02ab8
commit
7b3e757301
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user