vue-router
vue-router copied to clipboard
Press F5 to reload, it doesn't check permissions.
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()
}
})