routes.beforeEach((to, from, next) => { let token = Cookies('username'); if (!to.name) { next({ name: 'list' }); } else if (to.name == 'login') { if (!token || !store.state.auth.username) { next(); } else { next({ name: 'list' }); } } else if (to.params.status == 2 || (to.matched.some(record => record.meta.requiresAuth) && (!token || token === null))) { next({ path: '/login' }); } else { next(); } });