Преглед изворни кода

本地环境保存代码热更新会导致路径缺失问题

lifanagju_citu пре 8 месеци
родитељ
комит
d741ac9f09
2 измењених фајлова са 10 додато и 3 уклоњено
  1. 2 2
      src/permission.js
  2. 8 1
      src/utils/auth.js

+ 2 - 2
src/permission.js

@@ -12,14 +12,14 @@ const { start, done } = useNProgress()
 //            3.personalCommon: 无需登录也能访问的页面
 // 路由守卫
 router.beforeEach(async (to, from, next) => {
+  localStorage.setItem('routerTest', to.path) // 本地环境保存代码热更新会导致路径缺失问题
   start()
   // loadStart()
   if (to.path === '/enterpriseVerification') {
     // 校验企业必填信息
     useUserStore().checkEnterpriseBaseInfo()
     next()
-  }
-  if (getToken(to?.meta?.loginType === 'enterprise' ? 1 : 0)) {
+  } else if (getToken()) {
     if (to.path === '/login') {
       next({ path: '/recruitHome' })
     } else {

+ 8 - 1
src/utils/auth.js

@@ -2,8 +2,15 @@ import router from '@/router'
 
 const isEnterprise = () => {
   const currentRoute = router.currentRoute.value
-  let bool = currentRoute?.meta?.loginType === 'enterprise'
+  // let bool = currentRoute?.meta?.loginType === 'enterprise'
+  const substr = '/recruit/enterprise'
+  let bool = currentRoute?.path?.includes(substr)
   if (currentRoute?.path === '/enterpriseVerification') bool = true
+  const testUsePath = localStorage.getItem('routerTest')
+  if (currentRoute?.path === '/' && testUsePath?.includes(substr)) bool = true // 本地环境保存代码热更新会导致路径缺失问题
+  //
+  console.log('isEnterprise', bool)
+  console.log('currentRoute.path', currentRoute.path)
   return bool
 }