import router from './router'
import store from './store'
import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css' // Progress 进度条样式
import { Message } from 'element-ui'
import {
  userInfo, getAllmenus, getTyxydm
} from '@/api/login/login.js'

const whiteList = ['/login', '/userinfo'] // 不重定向白名单

router.beforeEach((to, from, next) => {
  NProgress.start()
  if (sessionStorage.getItem('TOKENL')) {
    //  首先走else 获取用户信息，然后不清空用户信息token，还是会跳转到首页
    next()
  } else {
    NProgress.done(true)
    location.replace(location.pathname + 'login.html')
  }
})

router.afterEach(() => {
  NProgress.done() // 结束Progress
})
