Commit d4e34c75 authored by guoyongchang's avatar guoyongchang
Browse files

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



后端返回 null (Go nil slice) 时前端访问 .length 抛出 TypeError,
在 API 层对 listByAccount 和 listResults 加 ?? [] 兜底。
Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 831abf79
...@@ -20,7 +20,7 @@ export async function listByAccount(accountId: number): Promise<ScheduledTestPla ...@@ -20,7 +20,7 @@ export async function listByAccount(accountId: number): Promise<ScheduledTestPla
const { data } = await apiClient.get<ScheduledTestPlan[]>( const { data } = await apiClient.get<ScheduledTestPlan[]>(
`/admin/accounts/${accountId}/scheduled-test-plans` `/admin/accounts/${accountId}/scheduled-test-plans`
) )
return data return data ?? []
} }
/** /**
...@@ -71,7 +71,7 @@ export async function listResults(planId: number, limit?: number): Promise<Sched ...@@ -71,7 +71,7 @@ export async function listResults(planId: number, limit?: number): Promise<Sched
params: limit ? { limit } : undefined params: limit ? { limit } : undefined
} }
) )
return data return data ?? []
} }
export const scheduledTestsAPI = { export const scheduledTestsAPI = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment