vue-router icon indicating copy to clipboard operation
vue-router copied to clipboard

Press F5 to reload, it doesn't check permissions.

Open nongtan7898 opened this issue 1 month ago • 0 comments

Press F5 to reload, it doesn't check permissions. If I press the normal path, it checks permissions. But when I go to one of the pages and press F5, it just returns to the home page even though I have permissions.

app.use(router)
import { useSidebarStore } from './stores/stores-components/store-sidebar/store-sidebar'
const storeSidebar = useSidebarStore()

router.beforeEach((to, from, next) => {
  let toHome = true
  console.log('Navigating to:', to.path)
  if (to.name != 'home') {
    console.log('TEST')
    storeSidebar._menuShow.forEach((element) => {
      element.subMenu.forEach((element2) => {
        if (element2.link == to.path) {
          toHome = false
        }
      })
    })
    if (toHome) {
      next({ name: 'home' })
    } else {
      next()
    }
  } else {
    next()
  }
})

nongtan7898 avatar Jul 01 '24 04:07 nongtan7898