|
@@ -22,6 +22,7 @@ const ENTERPRISE_PATH = '/recruit/enterprise'
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
start()
|
|
|
// 个人端 404 处理
|
|
|
+ // debugger
|
|
|
if (to.path === '/404') {
|
|
|
next()
|
|
|
return
|
|
@@ -70,12 +71,21 @@ router.beforeEach(async (to, from, next) => {
|
|
|
return
|
|
|
}
|
|
|
if (to.path === ENTERPRISE_PATH) {
|
|
|
- const firstPath = routes[0]
|
|
|
- if (!firstPath.children) {
|
|
|
- next(firstPath.path)
|
|
|
- } else {
|
|
|
- // 查找二级路由
|
|
|
- next(routes[0].children[0].path)
|
|
|
+ next(findPath(routes))
|
|
|
+ // const firstPath = routes[0]
|
|
|
+ // if (!firstPath.children) {
|
|
|
+ // next(firstPath.path)
|
|
|
+ // } else {
|
|
|
+ // // 查找二级路由
|
|
|
+ // next(routes[0].children[0].path)
|
|
|
+ // }
|
|
|
+ function findPath (nodes, root = '') {
|
|
|
+ const first = nodes[0]
|
|
|
+ const path = root + first.path
|
|
|
+ if (!first.children || !first.children.length) {
|
|
|
+ return path
|
|
|
+ }
|
|
|
+ return findPath(first.children, path + '/')
|
|
|
}
|
|
|
}
|
|
|
next({ ...to, replace: true })
|
|
@@ -112,19 +122,21 @@ router.beforeEach(async (to, from, next) => {
|
|
|
}
|
|
|
}
|
|
|
if (to.fullPath === '/login') {
|
|
|
- next({ path: '/recruitHome' })
|
|
|
+ next('/recruitHome')
|
|
|
+ return
|
|
|
}
|
|
|
// 获取字典信息
|
|
|
// const dictStore = useDictStore()
|
|
|
// dictStore.getDictTypeData()
|
|
|
next()
|
|
|
+ return
|
|
|
}
|
|
|
if (to.meta?.loginType === 'personalCommon' || to.meta?.loginType === 'common') { // 路由不重定向
|
|
|
next()
|
|
|
return
|
|
|
}
|
|
|
if (to.meta?.loginType === 'enterprise') { // 没有企业token->去个人首页
|
|
|
- next({ path: '/recruitHome' })
|
|
|
+ next('/recruitHome')
|
|
|
return
|
|
|
}
|
|
|
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
@@ -139,6 +151,8 @@ router.afterEach((to) => {
|
|
|
|
|
|
function hasRoute (path) {
|
|
|
const routes = router.getRoutes()
|
|
|
+ // console.log(routes.filter(item => item.path.includes('/recruit/enterprise')))
|
|
|
+ // debugger
|
|
|
return routeFlattening(routes).some(_path => {
|
|
|
if (_path.includes(':')) {
|
|
|
const change = path.split('/')
|