20200727-入园申请

This commit is contained in:
paidaxing444
2020-07-27 22:11:32 +08:00
parent 5cafc37152
commit c23ccd6420
10 changed files with 780 additions and 368 deletions

View File

@ -1,11 +1,17 @@
import router from './router'
import store from './store'
import { Message } from 'element-ui'
import {
Message
} from 'element-ui'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth'
import {
getToken
} from '@/utils/auth'
NProgress.configure({ showSpinner: false })
NProgress.configure({
showSpinner: false
})
//const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
const whiteList = ['/login']
@ -15,26 +21,35 @@ router.beforeEach((to, from, next) => {
if (getToken()) {
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
next({
path: '/'
})
NProgress.done()
} else {
if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(res => {
// 拉取user_info
const roles = res.roles
store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
// 测试 默认静态页面
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
// 拉取user_info
const roles = res.roles
store.dispatch('GenerateRoutes', {
roles
}).then(accessRoutes => {
// 测试 默认静态页面
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes) // 动态添加可访问路由表
next({
...to,
replace: true
}) // hack方法 确保addRoutes已完成
})
})
})
.catch(err => {
store.dispatch('FedLogOut').then(() => {
Message.error(err)
next({ path: '/' })
next({
path: '/'
})
})
})
} else {
@ -49,8 +64,9 @@ router.beforeEach((to, from, next) => {
}
}
} else {
//console.log(whiteList.indexOf(to.path));
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
if (whiteList.indexOf(to.path) !== -1 ||to.path.indexOf("/experience/choose/") != -1||to.path.indexOf("/experience/apply/") != -1||to.path.indexOf("/experience/result/") != -1) {
// 在免登录白名单,直接进入
next()
} else {