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.
bocai_supplyChain_pc/src/permission.js

51 lines
1.1 KiB
JavaScript

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