You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
459 B

import { router, useStore } from "/@/cool";
const ignoreToken = [
"/pages/index/home",
"/pages/index/website",
"/pages/index/admin",
"/pages/index/my",
"/pages/user/login",
"/pages/user/captcha",
"/pages/user/doc",
];
router.beforeEach((to, next) => {
const { user } = useStore();
if (ignoreToken.includes(to.path) || to.path.startsWith("/pages/demo")) {
next();
} else {
if (user.token) {
next();
} else {
router.login();
}
}
});