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
+17
View File
@@ -63,6 +63,22 @@ export const useStudyStore = defineStore("study", () => {
return null;
};
const ensureDefaultActiveStudy = async () => {
if (currentStudy.value) return currentStudy.value;
try {
const { data } = await fetchStudies();
const items = (data as any).items || [];
const active = items.find((study: Study) => study.status === "ACTIVE" && !study.is_locked);
if (active) {
setCurrentStudy(active as Study);
return active as Study;
}
} catch {
return null;
}
return null;
};
const clearCurrentStudy = () => {
currentStudy.value = null;
currentStudyRole.value = null;
@@ -106,6 +122,7 @@ export const useStudyStore = defineStore("study", () => {
setViewContext,
loadCurrentStudy,
ensureDefaultStudy,
ensureDefaultActiveStudy,
clearCurrentStudy,
};
});