本设计文档描述了项目管理界面的增强功能架构,包括项目完成状态管理和数据导出功能。设计遵循现有的组件架构和 API 模式。
ProjectDetailModal
├── Project Info Section
├── Action Buttons Section
│ ├── "标记为已完成" Button (conditional)
│ └── "导出数据" Button
├── Tasks Section
└── Modals
├── ProjectEditModal (existing)
├── ProjectCompletionDialog (new)
└── DataExportDialog (new)
API Endpoints
├── PATCH /api/projects/{project_id}/status (update status)
├── POST /api/projects/{project_id}/export (initiate export)
└── GET /api/exports/{export_id}/status (check export status)
PATCH /api/projects/{project_id}/status
Request: { status: "completed" }
Response: Project
POST /api/projects/{project_id}/export
Request: { format: "json" | "csv" | "coco" | "yolo" }
Response: { export_id: string, status: string }
GET /api/exports/{export_id}/status
Response: { status: string, progress: number, download_url?: string, error?: string }
interface ProjectCompletionState {
isDialogOpen: boolean;
isSubmitting: boolean;
error: string | null;
}
interface DataExportState {
isDialogOpen: boolean;
selectedFormat: ExportFormat | null;
isExporting: boolean;
exportProgress: number;
error: string | null;
downloadUrl: string | null;
}
type ExportFormat = 'json' | 'csv' | 'coco' | 'yolo';
class ProjectStatusUpdate(BaseModel):
status: str # "completed"
class ExportRequest(BaseModel):
format: str # "json", "csv", "coco", "yolo"
class ExportResponse(BaseModel):
export_id: str
status: str
progress: float
download_url: Optional[str]
error: Optional[str]
A property is a characteristic or behavior that should hold true across all valid executions of a system—essentially, a formal statement about what the system should do. Properties serve as the bridge between human-readable specifications and machine-verifiable correctness guarantees.
For any project with 100% completion rate, when the admin marks it as completed, the project status SHALL be updated to "completed" and remain in that state until explicitly changed.
Validates: Requirements 1.1, 1.3
For any project, the "标记为已完成" button SHALL be visible if and only if the project completion rate is exactly 100%.
Validates: Requirements 1.2, 2.2
For any export request, the selected format SHALL be one of the valid formats (JSON, CSV, COCO, YOLO), and the export SHALL fail gracefully if an invalid format is provided.
Validates: Requirements 3.1, 6.1
For any export job, the status returned by the status check endpoint SHALL be consistent with the actual export state, and progress SHALL be monotonically increasing.
Validates: Requirements 3.2, 6.2
For any project status update or export request, if the user is not an admin, the system SHALL return a 403 Forbidden error.
Validates: Requirements 5.5, 6.1
For any project marked as completed, the system SHALL record a completion timestamp that is greater than or equal to the current time.
Validates: Requirements 1.3
Status Update Errors
Export Errors
Network Errors
Invalid Status Transition
Incomplete Project
Export Failures
ProjectCompletionDialog
DataExportDialog
Backend Status Update
Status Update Property Test
Export Format Property Test
Authorization Property Test
Complete Project Workflow
Export Workflow