fix: 添加删除帖子的 mock handler

- 支持 DELETE /api/posts/:postId 请求
- 从内存存储中正确删除评论
- 修复 mock 模式下删除评论失败的问题

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-15 14:08:14 +08:00
parent 0775409c9f
commit d37cc720ef
3 changed files with 4 additions and 2 deletions

1
app.py
View File

@@ -10990,6 +10990,7 @@ def create_event_post(event_id):
'created_at': post.created_at.isoformat(), 'created_at': post.created_at.isoformat(),
'user': { 'user': {
'id': current_user.id, 'id': current_user.id,
'nickname': current_user.nickname, # 添加昵称,与导航区保持一致
'username': current_user.username, 'username': current_user.username,
'avatar_url': current_user.avatar_url 'avatar_url': current_user.avatar_url
} }

View File

@@ -1552,7 +1552,7 @@ export const eventHandlers = [
try { try {
// 从内存存储中删除评论 // 从内存存储中删除评论
let deleted = false; let deleted = false;
for (const [eventId, comments] of eventCommentsStore.entries()) { for (const [eventId, comments] of commentsStore.entries()) {
const index = comments.findIndex(c => String(c.id) === String(postId)); const index = comments.findIndex(c => String(c.id) === String(postId));
if (index !== -1) { if (index !== -1) {
comments.splice(index, 1); comments.splice(index, 1);

View File

@@ -210,7 +210,8 @@ export const eventService = {
...post, ...post,
author: post.user ? { author: post.user ? {
id: post.user.id, id: post.user.id,
username: post.user.username, // 与导航区保持一致:优先显示昵称
username: post.user.nickname || post.user.username,
avatar: post.user.avatar_url || post.user.avatar // 兼容 avatar_url 和 avatar avatar: post.user.avatar_url || post.user.avatar // 兼容 avatar_url 和 avatar
} : { } : {
id: 'anonymous', id: 'anonymous',