init.sql小bug修复-20260204
This commit is contained in:
@@ -476,16 +476,33 @@ router.beforeEach(async (to, _from, next) => {
|
||||
}
|
||||
}
|
||||
const token = getToken();
|
||||
const isAdmin = auth.user?.role === "ADMIN";
|
||||
if (token && !studyStore.currentStudy) {
|
||||
await studyStore.ensureDefaultStudy();
|
||||
if (isAdmin) {
|
||||
await studyStore.ensureDefaultActiveStudy();
|
||||
} else {
|
||||
await studyStore.ensureDefaultStudy();
|
||||
}
|
||||
}
|
||||
if (!to.meta.public && !token) {
|
||||
next({ path: "/login" });
|
||||
return;
|
||||
}
|
||||
if (isAdmin && (to.path === "/" || to.path === "/workbench")) {
|
||||
next({ path: studyStore.currentStudy ? "/project/overview" : "/admin/users" });
|
||||
return;
|
||||
}
|
||||
if ((to.path === "/login" || to.path === "/register") && token) {
|
||||
if (!auth.forceLogin) {
|
||||
next({ path: studyStore.currentStudy ? "/project/overview" : "/workbench" });
|
||||
next({
|
||||
path: isAdmin
|
||||
? studyStore.currentStudy
|
||||
? "/project/overview"
|
||||
: "/admin/users"
|
||||
: studyStore.currentStudy
|
||||
? "/project/overview"
|
||||
: "/workbench",
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -502,7 +519,7 @@ router.beforeEach(async (to, _from, next) => {
|
||||
}
|
||||
}
|
||||
if (to.meta.requiresStudy && !studyStore.currentStudy) {
|
||||
next({ path: "/workbench" });
|
||||
next({ path: isAdmin ? "/admin/users" : "/workbench" });
|
||||
return;
|
||||
}
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user