fix: 修复空结果导致定时测试模态框崩溃的问题

后端返回 null (Go nil slice) 时前端访问 .length 抛出 TypeError,
在 API 层对 listByAccount 和 listResults 加 ?? [] 兜底。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
guoyongchang
2026-03-05 16:47:01 +08:00
parent 831abf7977
commit d4e34c7514

View File

@@ -20,7 +20,7 @@ export async function listByAccount(accountId: number): Promise<ScheduledTestPla
const { data } = await apiClient.get<ScheduledTestPlan[]>(
`/admin/accounts/${accountId}/scheduled-test-plans`
)
return data
return data ?? []
}
/**
@@ -71,7 +71,7 @@ export async function listResults(planId: number, limit?: number): Promise<Sched
params: limit ? { limit } : undefined
}
)
return data
return data ?? []
}
export const scheduledTestsAPI = {