update [router]: 添加路由拦截参数from ,to.meta,使用to.meta实现登录拦截
This commit is contained in:
@@ -1,20 +1,9 @@
|
||||
import { router, useStore } from "@/cool";
|
||||
|
||||
const ignoreToken = [
|
||||
"/pages/index/home",
|
||||
"/pages/index/my",
|
||||
"/pages/index/template",
|
||||
"/pages/user/login",
|
||||
"/pages/user/doc"
|
||||
];
|
||||
|
||||
router.beforeEach((to, next) => {
|
||||
router.beforeEach((to, _, next) => {
|
||||
const { user } = useStore();
|
||||
|
||||
if (
|
||||
ignoreToken.some((e) => to.path.includes(e)) ||
|
||||
to.path.startsWith("/pages/demo") ||
|
||||
to.path.startsWith("/pages/template")
|
||||
!to.meta.isAuth
|
||||
) {
|
||||
next();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user