text: import Vue from 'vue'
  import router from './router'
  import store from './store'
  
  import NProgress from 'nprogress' // progress bar
  import '@/components/NProgress/nprogress.less' // progress bar custom style
  import notification from 'ant-design-vue/es/notification'
  import { setDocumentTitle, domTitle } from '@/utils/domUtil'
  import { ACCESS_TOKEN } from '@/store/mutation-types'
  
  NProgress.configure({ showSpinner: false }) // NProgress Configuration
  
  const whiteList = ['login', 'register', 'registerResult'] // no redirect whitelist
  const defaultRoutePath = '/dashboard/workplace'
  let num = 0
  router.beforeEach((to, from, next) => {
    NProgress.start() // start progress bar
    to.meta && typeof to.meta.title !== 'undefined' && setDocumentTitle(`${to.meta.title} - ${domTitle}`)
    if (Vue.ls.get(ACCESS_TOKEN)) {
      /* has token */
      console.log('存在token')
  
      if (to.path === '/user/login') {
        next({ path: defaultRoutePath })
        NProgress.done()
      } else {
        const redirect = decodeURIComponent(from.query.redirect || to.path)
        console.log('不校验行么？', redirect)
        num++
        next({ path: redirect })
      }
    } else {
      if (whiteList.includes(to.name)) {
        // 在免登录白名单，直接进入
        next()
      } else {
        console.log('没有token')
  
        notification.error({
          message: '错误',
          description: '请求用户信息失败，请重试'
        })
        store.dispatch('Logout').then(() => {
          next({ path: '/user/login', query: { redirect: to.fullPath } })
        })
        NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
      }
    }
  })
  
  router.afterEach(() => {
    NProgress.done() // finish progress bar
  })
  