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

34 lines
655 B
JavaScript

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