| | |
| | | import router from './router' |
| | | import store from './store' |
| | | import { Message } from 'element-ui' |
| | | import {Message} from 'element-ui' |
| | | import NProgress from 'nprogress' // progress bar |
| | | import 'nprogress/nprogress.css' // progress bar style |
| | | import { getCookie, getToken } from '@/utils/auth' // get token from cookie |
| | | import {getCookie, getToken} from '@/utils/auth' // get token from cookie |
| | | import getPageTitle from '@/utils/get-page-title' |
| | | |
| | | NProgress.configure({ showSpinner: false }) // NProgress Configuration |
| | | NProgress.configure({showSpinner: false}) // NProgress Configuration |
| | | |
| | | const whiteList = ['/login', '/jgcj','/zpcj'] // no redirect whitelist |
| | | const whiteList = ['/login', '/jgcj', '/zpcj', '/ckgl', '/zp1', '/zp2', '/zp3'] // no redirect whitelist |
| | | |
| | | router.beforeEach(async(to, from, next) => { |
| | | router.beforeEach(async (to, from, next) => { |
| | | // start progress bar |
| | | NProgress.start() |
| | | |
| | |
| | | if (hasToken) { |
| | | if (to.path === '/login') { |
| | | // if is logged in, redirect to the home page |
| | | next({ path: '/' }) |
| | | next({path: '/'}) |
| | | NProgress.done() |
| | | } else { |
| | | const hasGetUserInfo = store.getters.name |
| | |
| | | router.addRoutes(store.getters.addRouters) |
| | | |
| | | // hack方法 确保addRoutes已完成 |
| | | next({ ...to, replace: true }) |
| | | next({...to, replace: true}) |
| | | |
| | | // next() |
| | | } catch (error) { |