import router from './router'
import store from './store'
import {Message} from 'element-ui'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import {getUserInfo} from '@/utils/auth'
import {isRelogin} from '@/utils/request'

NProgress.configure({showSpinner: false})
const whiteList = ['/401', '/auth-redirect', '/bind', '/register']
router.beforeEach((to, from, next) => {
  NProgress.start()
  next()

  // if (getUserInfo()) {
  //   console.log("userInfo1",getUserInfo())
  //   next();
  // } else {
  //   if (to.query.token) {
  //     store.dispatch('GetInfo', to.query.token).then(() => {
  //       next(`${to.fullPath}`);
  //     }).catch(err => {
  //       next(`/401?redirect=${to.fullPath}`)
  //     })
  //   } else if (whiteList.indexOf(to.path) !== -1) {
  //     // 在免登录白名单，直接进入
  //     next()
  //   } else {
  //     next(`/401?redirect=${to.fullPath}`)
  //     NProgress.done()
  //   }
  // }
})

router.afterEach(() => {
  NProgress.done()
})
