On the problem of vue-router routing Guard

do another rights management module. The idea now is that when I log in, I directly generate the following code of router

.
  LoginByUsername({dispatch, commit, state}, loginForm) {
    const username = loginForm.username.trim()
    return new Promise((resolve, reject) => {
      loginByUsername(username, loginForm.password).then(response => {
        const data = response.result
        const meta = response.meta
        commit(SET_NAME, data.name)
        commit(SET_MENUFLAT, meta.flatMenus)
        commit(SET_MENUTREE, meta.treeMenus)
        /**/
        dispatch("generateRoutes").then((asyncRoute) => {
          console.log(state.addRouters)
          router.addRoutes(state.addRouters)
        })
        resolve()
      }).catch(error => {
        reject(error)
      })
    })
  },

here accessible routes are generated through router.addRoutes.
it"s OK to log in at first. After logging in, click on the menu bar to jump normally.

but if you press enter or refresh in the browser address column at this time, the route will fail
in

.

router.beforeEach((to, from, next) => {
  /*getters*/

  NProgress.start()
  /*token*/
  if (getToken()) {
    /*logn*/
    if (to.path === "/login") {
      next({path: "/"})
      NProgress.done()
    } else {
      next()
      NProgress.done()
    }
  } else {
    if (WhiteList.indexOf(to.path) !== -1) {
      next()
    } else {
      next("/login")
      NProgress.done()
    }
  }
})
The

breakpoint found that after refreshing the browser, the intercepted to here has no match matching address. Why

solve the puzzle

Mar.20,2021

the problem is that the addRoutes route fails after the page is refreshed, so judge and then regenerate the route

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-1eb6cd8-483bc.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-1eb6cd8-483bc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?