update [router]: 添加路由拦截参数from ,to.meta,使用to.meta实现登录拦截

This commit is contained in:
刘辉
2025-09-22 18:08:46 +08:00
parent d6c8fc16e6
commit dfad4ff040
4 changed files with 61 additions and 22 deletions

View File

@@ -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 {