router.beforeEach((to, from, next) => { if (to.path === '/login') return next() const token = sessionStorage.getItem('token') if (!token) return next('/login') next() })