unibest/src/utils/index.ts

21 lines
586 B
TypeScript
Raw Normal View History

2024-02-04 16:00:27 +08:00
import pagesJson from '@/pages.json'
2024-01-29 18:53:57 +08:00
2024-02-04 16:00:27 +08:00
console.log(pagesJson)
/** 判断当前页面是否是tabbar页 */
export const getIsTabbar = () => {
if (!Object.keys(pagesJson).includes('tabBar')) {
return false
}
const pages = getCurrentPages()
const lastPage = getArrElementByIdx(pages, -1)
const currPath = lastPage.route
2024-02-04 16:00:27 +08:00
return !!pagesJson.tabBar.list.find((e) => e.pagePath === currPath)
}
export const getArrElementByIdx = (arr: any[], index: number) => {
if (index < 0) return arr[arr.length + index]
if (index >= arr.length) return undefined
return arr[index]
}