from enum import Enum # 定义处理状态枚举 class ProcessStatus(Enum): IDLE = "idle" INITIALIZING = "initializing" COPYING_FILES = "copying_files" OCR_PROCESSING = "ocr_processing" LLM_PROCESSING = "llm_processing" EXTRACTING_QUESTIONS = "extracting_questions" SAVING_RESULTS = "saving_results" MOVING_FILES = "moving_files" COMPLETED = "completed" UPLOADING = "uploading" ERROR = "error" # 状态显示配置 STATUS_CONFIG = { ProcessStatus.IDLE: { "text": "🟢 待机中", "color": "green", "bold": False }, ProcessStatus.INITIALIZING: { "text": "🔄 初始化中...", "color": "blue", "bold": True }, ProcessStatus.COPYING_FILES: { "text": "📁 复制文件中...", "color": "blue", "bold": True }, ProcessStatus.OCR_PROCESSING: { "text": "🔍 OCR识别中...", "color": "orange", "bold": True }, ProcessStatus.LLM_PROCESSING: { "text": "🤖 LLM处理中...", "color": "purple", "bold": True }, ProcessStatus.EXTRACTING_QUESTIONS: { "text": "📝 提取题目中...", "color": "purple", "bold": True }, ProcessStatus.SAVING_RESULTS: { "text": "💾 保存结果中...", "color": "blue", "bold": True }, ProcessStatus.MOVING_FILES: { "text": "📦 移动文件中...", "color": "blue", "bold": True }, ProcessStatus.COMPLETED: { "text": "✅ 处理完成", "color": "green", "bold": True }, ProcessStatus.UPLOADING: { "text": "✅ 开始上传至存储", "color": "green", "bold": True }, ProcessStatus.ERROR: { "text": "❌ 处理出错", "color": "red", "bold": True } } def format_status_display(status: ProcessStatus, detail: str = ""): """格式化状态显示""" config = STATUS_CONFIG[status] text = config["text"] if detail: text += f" - {detail}" # 根据颜色和粗体设置返回HTML格式的文本 style = f"color: {config['color']};" if config["bold"]: style += " font-weight: bold;" return f'{text}'