From cf217ce68dcc207c4ecacb3a127f26e57ec51ad3 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 17 May 2026 13:22:49 +0800 Subject: [PATCH] auto-sync: 2026-05-17 13:22:49 --- src/frontend/src/store.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/store.ts b/src/frontend/src/store.ts index f163066..e707363 100644 --- a/src/frontend/src/store.ts +++ b/src/frontend/src/store.ts @@ -478,17 +478,29 @@ export const useStore = create((set, get) => ({ }, 3000); }, - // v2.6: 加载项目任务列表 + // v2.6: 加载项目任务列表(含聚合统计) loadV2Tasks: async () => { const pid = get().selectedProjectId; if (!pid) { set({ v2tasks: [] }); return; } set({ v2tasksLoading: true }); try { + // 获取任务列表 const res = await fetch(`/api/projects/${pid}/tasks`); - if (res.ok) { - const data = await res.json(); - set({ v2tasks: data.tasks || [] }); - } + if (!res.ok) { set({ v2tasks: [], v2tasksLoading: false }); return; } + const data = await res.json(); + const tasks = data.tasks || []; + // 批量获取聚合字段(comments_count, outputs_count, review_status, latest_event) + const enriched = await Promise.all(tasks.map(async (t: any) => { + try { + const r = await fetch(`/api/projects/${pid}/tasks/${t.id}`); + if (r.ok) { + const detail = await r.json(); + return { ...t, ...detail }; + } + } catch { /* skip enrichment */ } + return t; + })); + set({ v2tasks: enriched }); } catch { /* silently fail */ } finally { set({ v2tasksLoading: false }); } },