This commit is contained in:
icssoa
2025-10-16 18:28:57 +08:00
parent 18e9c41089
commit b7e0b36f92
3 changed files with 19 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { router, useStore } from "@/cool";
import { isNull, router, useStore } from "@/cool";
/**
* 路由跳转前的全局钩子(如修改 pages.json 后需重新编译项目以确保路由信息生效)
@@ -10,7 +10,7 @@ router.beforeEach((to, from, next) => {
const { user } = useStore();
// 判断是否需要登录
if (to.isAuth == true || to.meta?.isAuth == true) {
if (to.isAuth == true || (isNull(to.meta) ? true : to.meta.isAuth == true)) {
// 如果用户信息为空,则跳转到登录页
if (!user.isNull()) {
next();