| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import axios from 'axios'
- const api = axios.create({
- baseURL: '/api',
- timeout: 300000 // 5分钟超时,批量处理可能需要较长时间
- })
- /**
- * 文件对
- */
- export interface FilePair {
- json_path: string
- image_path: string
- }
- /**
- * 批量处理请求
- */
- export interface BatchProcessRequest {
- template_name: string
- file_pairs: FilePair[]
- output_dir: string
- parallel?: boolean
- adjust_rows?: boolean
- }
- /**
- * 批量处理结果
- */
- export interface BatchProcessResult {
- success: boolean
- json_path: string
- image_path: string
- structure_path?: string
- filename: string
- rows?: number
- cols?: number
- error?: string
- }
- /**
- * 批量处理响应
- */
- export interface BatchProcessResponse {
- success: boolean
- total: number
- processed: number
- failed: number
- results: BatchProcessResult[]
- message?: string
- }
- /**
- * 批量绘图请求
- */
- export interface DrawBatchRequest {
- results: BatchProcessResult[]
- line_width?: number
- line_color?: number[]
- }
- /**
- * 批量绘图响应
- */
- export interface DrawBatchResponse {
- success: boolean
- total: number
- drawn: number
- results: Array<{
- success: boolean
- image_path?: string
- filename: string
- error?: string
- }>
- message?: string
- }
- /**
- * 批量处理文件
- */
- export async function batchProcess(request: BatchProcessRequest): Promise<BatchProcessResponse> {
- const response = await api.post<BatchProcessResponse>('/batch/process', request)
- return response.data
- }
- /**
- * 批量绘制表格线
- */
- export async function batchDraw(request: DrawBatchRequest): Promise<DrawBatchResponse> {
- const response = await api.post<DrawBatchResponse>('/batch/draw', request)
- return response.data
- }
- /**
- * 健康检查
- */
- export async function healthCheck(): Promise<{ status: string; service: string }> {
- const response = await api.get('/batch/health')
- return response.data
- }
|