中文:收口权限与中心/立项配置改造

This commit is contained in:
Cheng Zhou
2026-05-12 10:16:52 +08:00
parent 6e90370a5f
commit 77e842637d
67 changed files with 706 additions and 669 deletions
+5 -5
View File
@@ -1,6 +1,7 @@
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import { useAuthStore } from "../store/auth";
import { useStudyStore } from "../store/study";
import { getProjectRole, isSystemAdmin } from "../utils/roles";
import Layout from "../components/Layout.vue";
import Login from "../views/Login.vue";
import Register from "../views/Register.vue";
@@ -477,7 +478,7 @@ router.beforeEach(async (to, _from, next) => {
}
}
token = getToken();
const isAdmin = auth.user?.role === "ADMIN";
const isAdmin = isSystemAdmin(auth.user);
if (token && !studyStore.currentStudy) {
if (isAdmin) {
await studyStore.ensureDefaultActiveStudy();
@@ -510,14 +511,13 @@ router.beforeEach(async (to, _from, next) => {
return;
}
}
if (to.meta.requiresAdmin && auth.user?.role !== "ADMIN") {
if (to.meta.requiresAdmin && !isAdmin) {
next({ path: "/workbench" });
return;
}
if (to.name === "AuditLogs") {
const role = auth.user?.role;
const studyRole = studyStore.currentStudyRole;
if (!(role === "ADMIN" || role === "PM" || studyRole === "PM")) {
const projectRole = getProjectRole(studyStore.currentStudy, studyStore.currentStudyRole);
if (!(isAdmin || projectRole === "PM")) {
next({ path: "/project/overview" });
return;
}