init.sql小bug修复-20260204
This commit is contained in:
@@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user