feat: add frontend support for dual-track processing

- Add ProcessingTrack, ProcessingMetadata types to apiV2.ts
- Add analyzeDocument, getProcessingMetadata, downloadUnified API methods
- Update startTask to support ProcessingOptions
- Update TaskDetailPage with:
  - Processing track badge and description display
  - Enhanced stats grid (pages, text regions, tables, images, confidence)
  - UnifiedDocument download option
  - Translation UI preparation (disabled, awaiting backend)
- Mark Section 7 Frontend Updates as completed in tasks.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-11-19 12:34:01 +08:00
parent 0fcb2492c9
commit c2288ba935
4 changed files with 299 additions and 36 deletions

View File

@@ -30,6 +30,9 @@ import type {
AuditLog,
AuditLogListResponse,
UserActivitySummary,
ProcessingOptions,
ProcessingMetadata,
DocumentAnalysisResponse,
} from '@/types/apiV2'
/**
@@ -385,10 +388,32 @@ class ApiClientV2 {
}
/**
* Start task processing
* Start task processing with optional dual-track settings
*/
async startTask(taskId: string): Promise<Task> {
const response = await this.client.post<Task>(`/tasks/${taskId}/start`)
async startTask(taskId: string, options?: ProcessingOptions): Promise<Task> {
const params = options ? {
use_dual_track: options.use_dual_track ?? true,
force_track: options.force_track,
language: options.language ?? 'ch',
} : {}
const response = await this.client.post<Task>(`/tasks/${taskId}/start`, null, { params })
return response.data
}
/**
* Analyze document to get recommended processing track
*/
async analyzeDocument(taskId: string): Promise<DocumentAnalysisResponse> {
const response = await this.client.get<DocumentAnalysisResponse>(`/tasks/${taskId}/analyze`)
return response.data
}
/**
* Get processing metadata for a completed task
*/
async getProcessingMetadata(taskId: string): Promise<ProcessingMetadata> {
const response = await this.client.get<ProcessingMetadata>(`/tasks/${taskId}/metadata`)
return response.data
}
@@ -475,6 +500,22 @@ class ApiClientV2 {
window.URL.revokeObjectURL(link.href)
}
/**
* Download task result as UnifiedDocument JSON
*/
async downloadUnified(taskId: string): Promise<void> {
const response = await this.client.get(`/tasks/${taskId}/download/unified`, {
responseType: 'blob',
})
const blob = new Blob([response.data], { type: 'application/json' })
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = `${taskId}_unified.json`
link.click()
window.URL.revokeObjectURL(link.href)
}
// ==================== Admin APIs ====================
/**