- 后端添加 PDF 转换服务,支持 Word(docx)、Excel(xlsx)、文本(txt)、Markdown(md) 格式转换为 PDF - 使用 reportlab 库,支持中文字体(simhei.ttf) - 添加 FastAPI 接口:POST /api/v1/pdf/convert 单文件转换,POST /api/v1/pdf/convert/batch 批量转换 - 前端添加 PdfConverter 页面,支持拖拽上传、转换进度显示、批量下载 - 转换流程:所有格式先转为 Markdown,再通过 Markdown 转 PDF,保证输出一致性 - DOCX 解析使用 zipfile 直接读取 XML,避免 python-docx 的兼容性问题的
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""
|
|
API 路由注册模块
|
|
"""
|
|
from fastapi import APIRouter
|
|
from app.api.endpoints import (
|
|
upload,
|
|
documents, # 多格式文档上传
|
|
tasks, # 任务管理
|
|
library, # 文档库
|
|
rag, # RAG检索
|
|
templates, # 表格模板
|
|
ai_analyze,
|
|
visualization,
|
|
analysis_charts,
|
|
health,
|
|
instruction, # 智能指令
|
|
conversation, # 对话历史
|
|
pdf_converter, # PDF转换
|
|
)
|
|
|
|
# 创建主路由
|
|
api_router = APIRouter()
|
|
|
|
# 注册各模块路由
|
|
api_router.include_router(health.router) # 健康检查
|
|
api_router.include_router(upload.router) # 原有Excel上传
|
|
api_router.include_router(documents.router) # 多格式文档上传
|
|
api_router.include_router(tasks.router) # 任务状态查询
|
|
api_router.include_router(library.router) # 文档库管理
|
|
api_router.include_router(rag.router) # RAG检索
|
|
api_router.include_router(templates.router) # 表格模板
|
|
api_router.include_router(ai_analyze.router) # AI分析
|
|
api_router.include_router(visualization.router) # 可视化
|
|
api_router.include_router(analysis_charts.router) # 分析图表
|
|
api_router.include_router(instruction.router) # 智能指令
|
|
api_router.include_router(conversation.router) # 对话历史
|
|
api_router.include_router(pdf_converter.router) # PDF转换
|