router.beforeEach((to, from, next) => {
let authUrlArr = ["/home/list", "/home/publish"];
let token = localStorage.getItem("token");
if (authUrlArr.includes(to.path)) {
// 进一步判断
if (token) {
next();
} else {
next("/login");
}
} else {
next();
}
});
router.beforeEach((to, from, next) => {
let authUrlArr = ["/home/list", "/home/publish"];
let token = localStorage.getItem("token");
if (authUrlArr.includes(to.path)) {
// 进一步判断
if (token) {
next();
} else {
next("/login");
}
} else {
next();
}
});