Skip to content

Commit

Permalink
Merge branch 'base'
Browse files Browse the repository at this point in the history
  • Loading branch information
codercup2 committed Jun 28, 2024
2 parents 9683916 + 357ed6c commit 878140a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { pages, subPackages, tabBar } from '@/pages.json'
const getLastPage = () => {
// getCurrentPages() 至少有1个元素,所以不再额外判断
// const lastPage = getCurrentPages().at(-1)
// 上面那个在低版本安卓中打包回报错,所以改用下面这个【虽然我加了src/interceptions/prototype.ts,但依然报错】
const pages = getCurrentPages()
return pages[pages.length - 1]
}

/** 判断当前页面是否是tabbar页 */
export const getIsTabbar = () => {
Expand All @@ -9,8 +16,7 @@ export const getIsTabbar = () => {
// 通常有tabBar的话,list不能有空,且至少有2个元素,这里其实不用处理
return false
}
// getCurrentPages() 至少有1个元素,所以不再额外判断
const lastPage = getCurrentPages().at(-1)
const lastPage = getLastPage()
const currPath = lastPage.route
return !!tabBar.list.find((e) => e.pagePath === currPath)
}
Expand All @@ -21,8 +27,7 @@ export const getIsTabbar = () => {
* redirectPath 如 ‘/pages/demo/base/route-interceptor’
*/
export const currRoute = () => {
// getCurrentPages() 至少有1个元素,所以不再额外判断
const lastPage = getCurrentPages().at(-1)
const lastPage = getLastPage()
const currRoute = (lastPage as any).$page
// console.log('lastPage.$page:', currRoute)
// console.log('lastPage.$page.fullpath:', currRoute.fullPath)
Expand Down

0 comments on commit 878140a

Please sign in to comment.