Browse Source

合并代码

lifanagju_citu 2 months ago
parent
commit
7b613bbb63
2 changed files with 13 additions and 12 deletions
  1. 0 1
      src/api/common/index.js
  2. 13 11
      src/permission.js

+ 0 - 1
src/api/common/index.js

@@ -254,7 +254,6 @@ export const userRefreshToken = async (refreshToken) => {
 // 招聘端-企业账户信息(积分&余额)
 export const getEnterpriseUserAccount = async () => {
   return await request.get({
-    // url: '/app-api/menduner/system/recruit/user/get/account'
     tokenIndex: 1, // 使用招聘token
     url: '/app-api/pay/currency/get' // 获取货币账户
   })

+ 13 - 11
src/permission.js

@@ -5,15 +5,14 @@ import { getToken, getIsEnterprise } from '@/utils/auth'
 // import { useDictStore } from '@/store/dict'
 import { useUserStore } from '@/store/user'
 import Confirm from '@/plugins/confirm'
+import fullScreen from '@/plugins/fullScreen'
 import dialogExtend from '@/plugins/dialogExtend'
 import { useMallStore } from '@/store/mall'
-import fullScreen from '@/plugins/fullScreen'
 
 const { start, done } = useNProgress()
-// loginType:1.enterprise: 企业路由
-//            2.personal: 个人路由
-//            3.common: 没有限制访问权限
-//            3.personalCommon: 无需登录也能访问的页面
+
+const TEACHER_PATH = '/recruit/teacher'
+
 // 路由守卫
 router.beforeEach(async (to, from, next) => {
   // 获取商城装修模版
@@ -21,11 +20,16 @@ router.beforeEach(async (to, from, next) => {
   if (!localStorage.getItem('mallTemplate')) {
     await mallStore.getMallDiyTemplate()
   }
-
-  localStorage.setItem('routerTest', to.path) // 本地环境保存代码热更新会导致路径缺失问题
   const tokenIndex = getIsEnterprise() ? 1: 2
+
   start()
-  // loadStart()
+  
+  const isTeacherRoute = to.path.includes(TEACHER_PATH)
+  const schoolInfo = localStorage.getItem('schoolInfo')
+  if (isTeacherRoute && !schoolInfo) {
+    next(`/login?redirect=${to.fullPath}`)
+  }
+  
   if (to.path === '/enterpriseVerification') {
     const res = JSON.parse(localStorage.getItem('emailLoginInfo') || "false")
     const obj = res ? { ...res, type: 'emailLogin' } : {}
@@ -70,10 +74,8 @@ router.beforeEach(async (to, from, next) => {
     // dictStore.getDictTypeData()
     next()
   } else {
-    if (to.meta?.loginType === 'personalCommon' || to.meta?.loginType === 'common') { // 路由不重定向
+    if (to.meta?.commonPage) { // 公共页面,路由不重定向
       next()
-    } else if (to.meta?.loginType === 'enterprise') { // 没有企业token->去个人首页
-      next({ path: '/recruitHome' })
     } else {
       next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
     }