center.js 575 B

1234567891011121314151617181920
  1. /**
  2. * 检查是否进入个人中心:path以/center开始或者name以center_开始
  3. * 不是进入个人中心,直接跳出
  4. * 是进入个人中心:
  5. * 1.检查是否已经注册路由:
  6. * 已注册: 跳过
  7. * 未注册:
  8. * 1.注册路由至一级的Layout下
  9. */
  10. export const isInCenter = (to) => {
  11. const { path } = to
  12. if (!path.includes('/center')) return false
  13. return true
  14. }
  15. export const hasCenterRoutes = (router, to) => {
  16. const routes = router.getRoutes()
  17. const thisRoute = routes.find((f) => f.path === to.path)
  18. return thisRoute
  19. }