On the problem of vue-router interceptor

my requirement is that the user opens the page, determines whether the index page (/ default is index) has login status, and continues without jumping login,. Now the problem is that I can"t block it by opening the index connector by default, and next directly. Then I click on other routes and intercept them when they return to the index page. What"s the problem? why can"t I intercept

in the first place?
Jul.22,2021

you can use beforeEach as a routing guard

router.beforeEach((to, from, next) => {
  // to and from are both route objects
  let login = sessionStorage['token'] || null
  let path = to.path
  if (path === '/login') {
    next()
    return
  }
  //  to.meta.requireAuth 
  let requireAuth = to.meta.requireAuth
  if (requireAuth) { // 
    if (!login) { // 
      next({
        path: '/login'
      })
    } else { // 
      next()
    }
  } else { // 
    next()
  }
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37abd-2b82d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37abd-2b82d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?