You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.5 KiB
JavaScript
67 lines
1.5 KiB
JavaScript
// 路由权限的配置
|
|
import router from "./router";
|
|
import Vue from "vue";
|
|
import Cookies from "js-cookie";
|
|
|
|
console.dir(Vue);
|
|
router.beforeEach(async (to, from, next) => {
|
|
// console.log(to);
|
|
// console.log(from);
|
|
// 路由守卫
|
|
console.log(to);
|
|
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",
|
|
];
|
|
if (localStorage.getItem("LOGIN_DATA")) {
|
|
var isLogin = true;
|
|
// next("/list");
|
|
}
|
|
// 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.fullPath == '/login') {
|
|
next('/list');
|
|
|
|
} else {
|
|
next();
|
|
|
|
}
|
|
} else {
|
|
if (whiteList.some((obj) => obj === to.path)) {
|
|
next();
|
|
} else {
|
|
next("/login");
|
|
}
|
|
}
|
|
});
|
|
router.afterEach(() => {
|
|
// const isLogin = sessionStorage.getItem("LOGIN_DATA") !== null ? true : false;
|
|
// if (isLogin) {
|
|
// if (to.path === "/list") {
|
|
// // next();
|
|
// window.location.reload();
|
|
// }
|
|
// }
|
|
// console.log(to);
|
|
// console.log(from);
|
|
// console.log(next);
|
|
});
|