|
@@ -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}`) // 否则全部重定向到登录页
|
|
|
}
|