This commit is contained in:
oneao committed 2026-03-25 17:31:22 +08:00
1 parent 11bcef03e1
commit a4e59dd5d1
39 files changed
+2333 -459

No files matched your search

+19 -6
View File
@@ -4,6 +4,7 @@ import { useUserStore } from "@/store/user";
import { ElMessage } from "element-plus";
import { useTabStore } from "@/store/tab";
import NProgress from "nprogress";
import { usePermissionStore } from "@/store/permission";
NProgress.configure({ easing: "ease", speed: 500 });
@@ -12,19 +13,31 @@ const router = createRouter({
routes,
});
router.beforeEach((to) => {
router.beforeEach(async (to) => {
NProgress?.start?.();
const userStore = useUserStore();
const permissionStore = usePermissionStore();
// if (!userStore.isLogined() && to.path !== "/login") {
// ElMessage.warning("登录已过期,请先登录");
// return "/login";
// }
if (!userStore.isLogined() && to.path !== "/login") {
ElMessage.warning("登录已过期,请先登录");
return "/login";
}
if (to.meta.moduleId) {
await permissionStore.init();
const hasPermission = permissionStore.hasModulePermission(to.meta.moduleId);
if (!hasPermission) {
ElMessage.warning("您没有权限访问此页面");
return "/";
}
}
handleTabPath(to);
return;
return true;
});
router.afterEach(() => {