auto-sync: 2026-05-20 18:19:36
This commit is contained in:
@@ -415,22 +415,26 @@ export const useStore = create<AppStore>((set, get) => ({
|
||||
set({ v2tasksLoading: true });
|
||||
try {
|
||||
if (!pid) {
|
||||
// 全部任务模式:聚合所有项目(排除 _mail)
|
||||
// 全部任务模式:聚合所有项目(排除 _mail),限制最多50个项目
|
||||
const projRes = await fetch('/api/projects');
|
||||
if (!projRes.ok) { set({ v2tasks: [], v2tasksLoading: false }); return; }
|
||||
const projData = await projRes.json();
|
||||
const allPids = Object.keys(projData.projects || {}).filter(p => !p.startsWith('_'));
|
||||
const allPids = Object.keys(projData.projects || {}).filter(p => !p.startsWith('_')).slice(0, 50);
|
||||
const allTasks: any[] = [];
|
||||
for (const p of allPids) {
|
||||
try {
|
||||
// 并行请求,每批10个
|
||||
for (let i = 0; i < allPids.length; i += 10) {
|
||||
const batch = allPids.slice(i, i + 10);
|
||||
const results = await Promise.allSettled(batch.map(async (p) => {
|
||||
const r = await fetch(`/api/projects/${p}/tasks`);
|
||||
if (r.ok) {
|
||||
const d = await r.json();
|
||||
for (const t of (d.tasks || [])) {
|
||||
allTasks.push({ ...t, _projectId: p, _projectName: (projData.projects[p] as any)?.name || p });
|
||||
}
|
||||
return (d.tasks || []).map((t: any) => ({ ...t, _projectId: p, _projectName: (projData.projects[p] as any)?.name || p }));
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
return [];
|
||||
}));
|
||||
for (const r of results) {
|
||||
if (r.status === 'fulfilled') allTasks.push(...r.value);
|
||||
}
|
||||
}
|
||||
set({ v2tasks: allTasks });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user