auto-sync: 2026-05-17 06:36:16

This commit is contained in:
cfdaily
2026-05-17 06:36:16 +08:00
parent 39cf47fb9b
commit 6b23bb4585
+8 -1
View File
@@ -24,7 +24,14 @@ async function fetchJSON<T>(url: string, options?: RequestInit): Promise<T> {
// ---- Projects ----
export async function listProjects(): Promise<Project[]> {
return fetchJSON('/projects');
const data = await fetchJSON<unknown>('/projects');
if (Array.isArray(data)) return data as Project[];
if (data && typeof data === 'object') {
const obj = data as Record<string, unknown>;
const projectsObj = ('projects' in obj ? obj.projects : obj) as Record<string, Project>;
return Object.values(projectsObj);
}
return [];
}
export async function getProject(projectId: string): Promise<Project> {