litian
2024-06-12 3a80faf0196f8dfa1b6cdb26ece68b37842c66b1
src/main.ts
@@ -17,23 +17,24 @@
// 路由执行之前的一些操作
router.beforeEach((to, from, next) => {
  if (handleGetToken()) {
    // 是否是登录页面,直接到首页
    if (to.path === '/login') {
      next({ path: '/home',query: { bookId: localStorage.getItem('bookId') } })
    } else {
      // 如果不是登录页面,跳转到目标的页面
      next()
    }
  } else {
    // 没有token
    if (!to.meta || !to.meta.auth) {
      // 在免登录白名单,直接进入
      next()
    } else {
      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
    }
  }
  next()
  // if (handleGetToken()) {
  //   // 是否是登录页面,直接到首页
  //   if (to.path === '/login') {
  //     next({ path: '/home', query: { bookId: localStorage.getItem('bookId') } })
  //   } else {
  //     // 如果不是登录页面,跳转到目标的页面
  //     next()
  //   }
  // } else {
  //   // 没有token
  //   if (!to.meta || !to.meta.auth) {
  //     // 在免登录白名单,直接进入
  //     next()
  //   } else {
  //     next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
  //   }
  // }
})
// qiankun主应用与微应用通讯