task-106(任务与重复分析中心): 实现视频任务批量下载任务
新增 image-video-download.ts(选择键解析/打包请求体/响应头计数/下载 job 状态), image-video-api.ts 增加 requestVideoZipDownload(POST /download-zip, blob)。 TDD: task-106.test.ts 8 用例先 RED 后 GREEN。
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
/** 视频任务列表/详情适配(任务 103/104):GET /api/admin/image-video-tasks(/detail)。 */
|
||||
/** 视频任务列表/详情/批量下载适配(任务 103-106)。 */
|
||||
import { http } from '@/api/http'
|
||||
import { parseImageVideoDetail, parseImageVideoPage, type ImageVideoDetail, type ImageVideoPageResult } from './image-video-model.ts'
|
||||
import { toImageVideoQuery, type ImageVideoFilter } from './image-video-filter.ts'
|
||||
import { downloadZipHeaderCounts, toVideoZipRequest } from './image-video-download.ts'
|
||||
|
||||
export const IMAGE_VIDEO_TASKS_ENDPOINT = '/api/admin/image-video-tasks'
|
||||
|
||||
@@ -21,3 +22,18 @@ export async function fetchImageVideoTaskDetail(taskId: string | number): Promis
|
||||
const { data } = await http.get<unknown>(`${IMAGE_VIDEO_TASKS_ENDPOINT}/${taskId}`)
|
||||
return parseImageVideoDetail(data)
|
||||
}
|
||||
|
||||
export interface VideoZipDownloadResult {
|
||||
blob: Blob
|
||||
fileCount?: number
|
||||
errorCount?: number
|
||||
}
|
||||
|
||||
/** 批量打包下载视频:POST /download-zip(blob);从响应头读成功/失败计数。 */
|
||||
export async function requestVideoZipDownload(keys: readonly string[]): Promise<VideoZipDownloadResult> {
|
||||
const { data, headers } = await http.post<Blob>(`${IMAGE_VIDEO_TASKS_ENDPOINT}/download-zip`, toVideoZipRequest(keys), {
|
||||
responseType: 'blob',
|
||||
})
|
||||
const counts = downloadZipHeaderCounts(headers as Record<string, string>)
|
||||
return { blob: data, fileCount: counts.fileCount, errorCount: counts.errorCount }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user