import router from '@/router/index'
import { getTokenCookies } from '@/utils/auth'

const whiteList = ['/login', '/404']

router.beforeEach((to, from, next) => {
  const token = getTokenCookies()
  if (!token) {
    if (whiteList.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  } else {
    next()
  }
})
