feat(data-process): 优化上传切分流程与PDF高亮预览
This commit is contained in:
@@ -3,6 +3,7 @@ import type {
|
||||
DataProcessExternalSourcePayload,
|
||||
DataProcessExternalTestResult,
|
||||
DataProcessPage,
|
||||
DataProcessPdfPages,
|
||||
DataProcessPreviewBuildPayload,
|
||||
DataProcessPreviewBuildResult,
|
||||
DataProcessPreviewCreatePayload,
|
||||
@@ -27,8 +28,13 @@ export type {
|
||||
DataProcessExternalSourcePayload,
|
||||
DataProcessExternalTestResult,
|
||||
DataProcessPage,
|
||||
DataProcessPdfPageRange,
|
||||
DataProcessPdfPages,
|
||||
DataProcessPreviewBuildPayload,
|
||||
DataProcessPreviewBuildFileResult,
|
||||
DataProcessPreviewBuildResult,
|
||||
DataProcessPreviewFileBuildProgress,
|
||||
DataProcessPreviewFileStatus,
|
||||
DataProcessPreviewCreatePayload,
|
||||
DataProcessPreviewItem,
|
||||
DataProcessPreviewUpdatePayload,
|
||||
@@ -71,13 +77,25 @@ export const updateDataProcessTask = (taskId: string | number, payload: DataProc
|
||||
export const deleteDataProcessTask = (taskId: string | number) =>
|
||||
del<{ deleted: string | number }>(`/data-process/${encodeURIComponent(taskId)}`)
|
||||
|
||||
export function uploadDataProcessSourceFiles(taskId: string | number, files: File[]) {
|
||||
export function uploadDataProcessSourceFiles(
|
||||
taskId: string | number,
|
||||
files: File[],
|
||||
onProgress?: (progress: number) => void,
|
||||
) {
|
||||
const formData = new FormData()
|
||||
files.forEach((file) => formData.append('files', file))
|
||||
return post<{ files: DataProcessSourceFile[] }>(
|
||||
`/data-process/${encodeURIComponent(taskId)}/source-files`,
|
||||
formData,
|
||||
{ headers: { 'Content-Type': 'multipart/form-data' } },
|
||||
{
|
||||
timeout: 5 * 60 * 1000,
|
||||
onUploadProgress: (event) => {
|
||||
if (!event.total) return
|
||||
// 发送完成不等于服务端解析完成;收到成功响应前最多展示 99%。
|
||||
const progress = Math.round((event.loaded / event.total) * 100)
|
||||
onProgress?.(Math.min(99, Math.max(0, progress)))
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -95,6 +113,18 @@ export const getDataProcessSourceContent = (
|
||||
params,
|
||||
)
|
||||
|
||||
export const getDataProcessSourceRawUrl = (
|
||||
taskId: string | number,
|
||||
fileId: string | number,
|
||||
) => `/modelTF/data-process/${encodeURIComponent(taskId)}/source-files/${encodeURIComponent(fileId)}/raw`
|
||||
|
||||
export const getDataProcessPdfPages = (
|
||||
taskId: string | number,
|
||||
fileId: string | number,
|
||||
) => get<DataProcessPdfPages>(
|
||||
`/data-process/${encodeURIComponent(taskId)}/source-files/${encodeURIComponent(fileId)}/pdf-pages`,
|
||||
)
|
||||
|
||||
export const testDataProcessExternalSource = (
|
||||
taskId: string | number,
|
||||
payload: DataProcessExternalSourcePayload,
|
||||
@@ -120,6 +150,7 @@ export const buildDataProcessPreview = (
|
||||
) => post<DataProcessPreviewBuildResult>(
|
||||
`/data-process/${encodeURIComponent(taskId)}/preview/build`,
|
||||
payload,
|
||||
{ timeout: 5 * 60 * 1000 },
|
||||
)
|
||||
|
||||
export function getDataProcessPreview(
|
||||
|
||||
Reference in New Issue
Block a user