Files
xiaoxia-saas/apps/web/src/api/duplication.ts
T
xiaoxia 0fcb77b991
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 2m50s
CI Build & Deploy Pipeline / Production Browser E2E (push) Failing after 1437h19m24s
CI Build & Deploy Pipeline / Build Production Web Image (push) Failing after 1437h19m26s
CI Build & Deploy Pipeline / Deploy Production (push) Failing after 1437h19m25s
CI Build & Deploy Pipeline / Build Production API Image (push) Failing after 1437h19m26s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1437h21m16s
CI Build & Deploy Pipeline / Build Staging API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Staging Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Failing after 1437h51m29s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
ci: Prettier纳入两层防御体系 (#520)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-07-18 18:08:19 +08:00

100 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 查重 API 模块
* 提供视频查重相关接口
*/
import apiClient from "./client"
/** 查重记录状态 */
export type DuplicationStatus = "pending" | "processing" | "completed" | "failed"
/** 查重记录 */
export interface DuplicationRecord {
id: string
/** 原始文件名 */
filename: string
/** 文件大小(字节) */
file_size: number
/** 时长(秒) */
duration_seconds?: number
/** 状态 */
status: DuplicationStatus
/** 查重率(0-100) */
duplicate_rate?: number
/** 重复片段数 */
duplicate_count?: number
/** 创建时间 */
created_at: string
/** 更新时间 */
updated_at: string
}
/** 重复片段详情 */
export interface DuplicateSegment {
id: string
/** 在原始视频中的起始时间(秒) */
source_start: number
/** 在原始视频中的结束时间(秒) */
source_end: number
/** 匹配到的已有视频 ID */
matched_video_id: string
/** 匹配到的已有视频名称 */
matched_video_name: string
/** 匹配片段在已有视频中的起始时间 */
matched_start: number
/** 匹配片段在已有视频中的结束时间 */
matched_end: number
/** 相似度(0-100) */
similarity: number
}
/** 查重详情 */
export interface DuplicationDetail extends DuplicationRecord {
/** 重复片段列表 */
segments: DuplicateSegment[]
}
/** 上传查重响应 */
export interface DuplicationUploadResponse {
/** 查重记录 ID */
id: string
/** 状态 */
status: DuplicationStatus
/** 消息 */
message: string
}
// ============ API 函数 ============
/** 上传视频进行查重 */
export const uploadForDuplication = async (file: File): Promise<DuplicationUploadResponse> => {
const formData = new FormData()
formData.append("file", file)
const response = await apiClient.post("/duplication/upload", formData, {
headers: { "Content-Type": "multipart/form-data" },
})
return response.data
}
/** 获取查重记录列表 */
export const getDuplicationRecords = async (): Promise<DuplicationRecord[]> => {
const response = await apiClient.get("/duplication/records")
return response.data
}
/** 获取查重详情 */
export const getDuplicationDetail = async (recordId: string): Promise<DuplicationDetail> => {
const response = await apiClient.get(`/duplication/records/${recordId}`)
return response.data
}
/** 删除查重记录 */
export const deleteDuplicationRecord = async (recordId: string): Promise<void> => {
await apiClient.delete(`/duplication/records/${recordId}`)
}
/** 重新查重 */
export const retryDuplication = async (recordId: string): Promise<DuplicationUploadResponse> => {
const response = await apiClient.post(`/duplication/records/${recordId}/retry`)
return response.data
}