This commit is contained in:
beabigegg
2025-11-12 22:53:17 +08:00
commit da700721fa
130 changed files with 23393 additions and 0 deletions

174
frontend/src/types/api.ts Normal file
View File

@@ -0,0 +1,174 @@
/**
* API Type Definitions
* Based on backend OpenAPI specification
*/
// Authentication
export interface LoginRequest {
username: string
password: string
}
export interface LoginResponse {
access_token: string
token_type: string
}
export interface User {
id: number
username: string
}
// File Upload
export interface UploadResponse {
batch_id: number
files: FileInfo[]
}
export interface FileInfo {
id: number
filename: string
file_size: number
format: string
status: 'pending' | 'processing' | 'completed' | 'failed'
}
// OCR Processing
export interface ProcessRequest {
batch_id: number
lang?: string
confidence_threshold?: number
}
export interface ProcessResponse {
task_id: string
batch_id: number
status: string
}
export interface TaskStatus {
task_id: string
status: 'pending' | 'processing' | 'completed' | 'failed'
progress_percentage: number
current_file?: string
files_processed: number
total_files: number
error?: string
}
export interface BatchStatus {
batch: {
id: number
status: 'pending' | 'processing' | 'completed' | 'failed'
progress_percentage: number
created_at: string
completed_at?: string
}
files: FileResult[]
}
export interface FileResult {
id: number
filename: string
status: 'pending' | 'processing' | 'completed' | 'failed'
processing_time?: number
error?: string
}
// OCR Results
export interface OCRResult {
file_id: number
filename: string
status: string
markdown_content: string
json_data: OCRJsonData
confidence: number
processing_time: number
}
export interface OCRJsonData {
total_text_regions: number
average_confidence: number
text_blocks: TextBlock[]
layout_info?: LayoutInfo
}
export interface TextBlock {
text: string
confidence: number
bbox: [number, number, number, number]
position: number
}
export interface LayoutInfo {
tables_detected: number
images_detected: number
structure: string
}
// Export
export interface ExportRequest {
batch_id: number
format: 'txt' | 'json' | 'excel' | 'markdown' | 'pdf'
rule_id?: number
options?: ExportOptions
}
export interface ExportOptions {
confidence_threshold?: number
include_metadata?: boolean
filename_pattern?: string
css_template?: string
}
export interface ExportRule {
id: number
rule_name: string
config_json: Record<string, any>
css_template?: string
created_at: string
}
export interface CSSTemplate {
name: string
description: string
filename: string
}
// Translation (FUTURE FEATURE)
export interface TranslateRequest {
file_id: number
source_lang: string
target_lang: string
engine_type?: 'argos' | 'ernie' | 'google'
}
export interface TranslateResponse {
task_id: string
file_id: number
status: 'pending' | 'processing' | 'completed' | 'failed'
translated_content?: string
}
export interface TranslationConfig {
id: number
source_lang: string
target_lang: string
engine_type: 'argos' | 'ernie' | 'google'
engine_config: Record<string, any>
created_at: string
}
// API Response
export interface ApiResponse<T = any> {
success: boolean
data?: T
error?: string
message?: string
}
// Error Response
export interface ApiError {
detail: string
status_code: number
}