物业之前,新工作台

This commit is contained in:
Zy
2026-04-16 21:03:35 +08:00
parent cf9a1f1585
commit 4184f1c55d
91 changed files with 1781 additions and 588 deletions

View File

@@ -31,8 +31,7 @@ router.beforeEach(async (to, from, next) => {
if (useUserStore().roles.length === 0) {
isRelogin.show = true;
// 判断当前用户是否已拉取完user_info信息
const [data, err] = await tos(useUserStore().getInfo());
console.log(data);
const [err, res] = await tos(useUserStore().getInfo());
if (err) {
await useUserStore().logout();
ElMessage.error(err);
@@ -46,8 +45,13 @@ router.beforeEach(async (to, from, next) => {
router.addRoute(route); // 动态添加可访问路由表
}
});
// @ts-expect-error hack方法 确保addRoutes已完成
next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
if (res.user.userId === 1 && from.path === '/login') {
// 管理员 → 强制跳转到社区列表
next('/community/communitylist');
} else {
// 普通用户 → 正常跳转目标页
next(to.fullPath);
}
}
} else {
next();
@@ -59,8 +63,7 @@ router.beforeEach(async (to, from, next) => {
// 在免登录白名单,直接进入
next();
} else {
const redirect = encodeURIComponent(to.fullPath || '/');
next(`/login?redirect=${redirect}`); // 否则全部重定向到登录页
next(`/login`); // 否则全部重定向到登录页
NProgress.done();
}
}