Add conversation deletion functionality and update HistoryPage

- Implement a new API endpoint for deleting conversations in the backend.
- Enhance the HistoryPage component to include a dropdown menu for conversation actions, allowing users to delete conversations.
- Update the pagination logic to handle conversation removal and improve user experience during deletion.
- Adjust the loading state and error handling for the delete operation, ensuring smooth interaction.
This commit is contained in:
Xin Wang
2026-07-10 16:38:59 +08:00
parent 059ad8162e
commit ba59ea447c
3 changed files with 127 additions and 18 deletions

View File

@@ -115,3 +115,16 @@ async def get_conversation(
for message in messages
],
)
@router.delete("/{conversation_id}")
async def delete_conversation(
conversation_id: str,
session: AsyncSession = Depends(get_session),
):
conversation = await session.get(ConversationSession, conversation_id)
if not conversation:
raise HTTPException(404, "对话记录不存在")
await session.delete(conversation)
await session.commit()
return {"ok": True}