|
|
|
@ -11,62 +11,50 @@ function kickOut() {
|
|
|
|
|
location.href = location.origin + "/login";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const whiteList = [
|
|
|
|
|
"/404",
|
|
|
|
|
"/401",
|
|
|
|
|
// const whiteList = [
|
|
|
|
|
// "/404",
|
|
|
|
|
// "/401",
|
|
|
|
|
// '/drugArchives',
|
|
|
|
|
// "/cosmeticsArchives",
|
|
|
|
|
"/cosmeticsDetail",
|
|
|
|
|
"/health",
|
|
|
|
|
"/zyzj",
|
|
|
|
|
];
|
|
|
|
|
// "/cosmeticsDetail",
|
|
|
|
|
// "/health",
|
|
|
|
|
// "/zyzj",
|
|
|
|
|
// ];
|
|
|
|
|
NProgress.configure({ showSpinner: false });
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
NProgress.start();
|
|
|
|
|
|
|
|
|
|
let token = localStorage.getItem('MSSM-LIAONING__TOKEN')
|
|
|
|
|
console.log(to.path);
|
|
|
|
|
if (whiteList.indexOf(to.path) == -1) {
|
|
|
|
|
if (token) {
|
|
|
|
|
console.log(store.state.myselfPermission.routerList,'store.state.myselfPermission.routerList')
|
|
|
|
|
if (store.state.myselfPermission.routerList.length > 0) {
|
|
|
|
|
let current = store.state.myselfPermission.routerList.filter(
|
|
|
|
|
(item) => item.path == to.path || from.path == "/"
|
|
|
|
|
);
|
|
|
|
|
console.log(current,'current')
|
|
|
|
|
if (current.length > 0) {
|
|
|
|
|
if (token) {
|
|
|
|
|
if (store.state.myselfPermission.routerList.length == 0) {
|
|
|
|
|
|
|
|
|
|
store.dispatch("GetPermission").then((res) => {
|
|
|
|
|
next({path:to.path});
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
kickOut();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
let current = store.state.myselfPermission.routerList.filter(
|
|
|
|
|
(item) => item.path == to.path || from.path == "/"
|
|
|
|
|
);
|
|
|
|
|
if (current.length > 0) {
|
|
|
|
|
next();
|
|
|
|
|
} else {
|
|
|
|
|
//根据参数判断是否可以跳
|
|
|
|
|
if (to.query.type && to.path == '/cosmeticsDetail') {
|
|
|
|
|
next();
|
|
|
|
|
} else {
|
|
|
|
|
//根据参数判断是否可以跳
|
|
|
|
|
if (to.query.type && to.path == '/cosmeticsDetail') {
|
|
|
|
|
next();
|
|
|
|
|
} else {
|
|
|
|
|
next()
|
|
|
|
|
Message.error("无权限访问!");
|
|
|
|
|
}
|
|
|
|
|
Message.error("无权限访问!");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
store
|
|
|
|
|
.dispatch("GetPermission")
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log(res,'res')
|
|
|
|
|
if (res.length > 0) {
|
|
|
|
|
next({ path: res });
|
|
|
|
|
} else {
|
|
|
|
|
kickOut();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
kickOut();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 没有token
|
|
|
|
|
Message.error("获取令牌失败!");
|
|
|
|
|
kickOut();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 没有token
|
|
|
|
|
Message.error("获取令牌失败!");
|
|
|
|
|
kickOut();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
router.afterEach(() => {
|
|
|
|
|