Forráskód Böngészése

feat(utils): 添加判断当前页面是否为tabbar页面的功能

新增isCurrentPageTabbar函数,用于检查当前页面是否属于tabbar配置中的页面
feige996 9 hónapja
szülő
commit
498ddcd04b
1 módosított fájl, 8 hozzáadás és 0 törlés
  1. 8 0
      src/utils/index.ts

+ 8 - 0
src/utils/index.ts

@@ -1,4 +1,5 @@
 import { pages, subPackages } from '@/pages.json'
+import { tabbarList } from '@/tabbar/config'
 import { isMpWeixin } from './platform'
 
 export function getLastPage() {
@@ -9,6 +10,13 @@ export function getLastPage() {
   return pages[pages.length - 1]
 }
 
+export function isCurrentPageTabbar() {
+  const lastPage = getLastPage()
+  const currRoute = (lastPage as any).$page
+  const { fullPath } = currRoute as { fullPath: string }
+  return tabbarList.some(item => `/${item.path}` === fullPath)
+}
+
 /**
  * 获取当前页面路由的 path 路径和 redirectPath 路径
  * path 如 '/pages/login/index'