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:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user