// 路由权限的配置 import router from "./router"; router.beforeEach(async (to, from, next) => { // console.log(to); // console.log(from); // 路由守卫 console.log(from); // if (from.fullPath === "/list") { // // console.log(213); // sessionStorage.setItem("ISLIST", JSON.stringify(true)); // } else { // sessionStorage.setItem("ISLIST", JSON.stringify(false)); // } const whiteList = [ // 设置白名单 "/login", "/404", "/serviceoutlets", "/aboutus", "/main", "/updatepsw", // "/register", ]; const isLogin = sessionStorage.getItem("LOGIN_DATA") !== null ? true : false; // const isLogin = localStorage.getItem("LOGIN_DATA") !== null ? true : false; // if (to.fullPath === from.fullPath) { // next(to.path); // } // console.log(isLogin); // 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(() => {});