init.sql小bug修复-20260204

This commit is contained in:
Cheng Zhou
2026-02-04 16:17:51 +08:00
parent 737f84bf54
commit 0693f09b1d
4 changed files with 97 additions and 207 deletions
+20 -3
View File
@@ -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();