From fb4ccad4028350fa109e56add404ebd148a838e2 Mon Sep 17 00:00:00 2001 From: xiamuceer Date: Wed, 19 Nov 2025 14:35:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:1.=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=AB=A0=E8=8A=82=E6=97=B6=E6=9C=AA=E6=B8=85=E7=90=86=E6=8E=89?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E5=90=91=E9=87=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/chapters.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/app/api/chapters.py b/backend/app/api/chapters.py index 6cfc0a6..87cde3b 100644 --- a/backend/app/api/chapters.py +++ b/backend/app/api/chapters.py @@ -344,6 +344,19 @@ async def delete_chapter( if project: project.current_words = max(0, project.current_words - chapter.word_count) + # 🗑️ 清理向量数据库中的记忆数据 + try: + await memory_service.delete_chapter_memories( + user_id=user_id, + project_id=chapter.project_id, + chapter_id=chapter_id + ) + logger.info(f"✅ 已清理章节 {chapter_id[:8]} 的向量记忆数据") + except Exception as e: + logger.warning(f"⚠️ 清理向量记忆数据失败: {str(e)}") + # 不阻断删除流程,继续执行 + + # 删除章节(关系数据库中的记忆会被级联删除) await db.delete(chapter) await db.commit()