Browse Source

是否是教师。没有教师信息则不是

lifanagju_citu 2 months ago
parent
commit
e894373b1a
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/permission.js

+ 8 - 1
src/permission.js

@@ -14,7 +14,7 @@ const { start, done } = useNProgress()
 
 
 let isRefresh = true
 let isRefresh = true
 const ENTERPRISE_PATH = '/recruit/enterprise'
 const ENTERPRISE_PATH = '/recruit/enterprise'
-// const TEACHER_PATH = '/recruit/teacher'
+const TEACHER_PATH = '/recruit/teacher'
 
 
 // 路由守卫
 // 路由守卫
 router.beforeEach(async (to, from, next) => {
 router.beforeEach(async (to, from, next) => {
@@ -24,11 +24,18 @@ router.beforeEach(async (to, from, next) => {
     next()
     next()
     return
     return
   }
   }
+
   const isEnterprise = to.path.includes(ENTERPRISE_PATH)
   const isEnterprise = to.path.includes(ENTERPRISE_PATH)
   if (!isEnterprise && to.path !== '/enterpriseVerification' && !hasRoute(to.path)) {
   if (!isEnterprise && to.path !== '/enterpriseVerification' && !hasRoute(to.path)) {
     next('/404')
     next('/404')
   }
   }
   
   
+  const isTeacherRoute = to.path.includes(TEACHER_PATH)
+  const schoolInfo = localStorage.getItem('schoolInfo')
+  if (isTeacherRoute && !schoolInfo) {
+    next(`/login?redirect=${to.fullPath}`)
+  }
+  
   const tokenIndex = isEnterprise ? 1 : 2 // 1:企业 2:个人
   const tokenIndex = isEnterprise ? 1 : 2 // 1:企业 2:个人
 
 
   // 获取商城装修模版
   // 获取商城装修模版