// 路由权限的配置 import router from "./router"; router.beforeEach(async (to, from, next) => { console.log(to); console.log(from); // 路由守卫 const whiteList = [ "/login", "/404", "/serviceoutlets", "/aboutus", "/main", "/updatepsw", ]; // 设置白名单 const isLogin = localStorage.getItem("LOGIN_DATA") !== null ? true : false; // if (to.fullPath === from.fullPath) { // next(to.path); // } console.log(to); if (isLogin) { if (to.path === "/login") { next("/login"); } else { next(); } } else { if ( whiteList.some((obj) => { return obj === to.path; }) ) { next(); } else { next("/login"); } } }); router.afterEach(() => {});