refactor(feed): 举报与删除按钮从列表卡片移到帖子详情页

举报和删除针对的是帖子内容本身,放在列表卡片上容易被理解为对整张
卡片操作,也容易误点(卡片本身可点击进入详情)。现统一移到详情页。

- 列表卡片底部只保留回复数,不再有任何按钮
- 详情页新增举报按钮(此前详情页只有置顶 / 编辑 / 删除,反而缺少
  举报入口)。按钮仅在登录后显示;提交逻辑仍复用 app.js 中
  reportTargetPostId 的既有流程,此处只负责记录目标并打开弹窗
- 移除 feed.js 中随之失效的 .action-report / .action-delete 事件绑定,
  避免留下死代码

详情页原有的删除按钮保留,卡片上那份去掉,因此删除入口从两个减为一个。

实测(Puppeteer,1280px 视口):
- 首页卡片内按钮总数为 0,底部仅显示「N 条回复」
- 详情页按钮:置顶、举报(编辑与删除仅作者本人可见,测试帖作者为
  另一账号,故未出现)
- 点击举报按钮后 reportModal 的 class 由 modal 变为 modal active,
  计算样式 display 为 flex,reportTargetPostId 正确写入帖子 ID

完整测试套件 25/25 通过。
This commit is contained in:
Furrium Network committed 2026-09-22 19:50:43 +08:00
1 parent 74204f7bb2
commit 17b6ee35ef
2 files changed
+19 -30

No files matched your search

+14
View File
@@ -88,6 +88,10 @@ async function renderPostDetail(postId) {
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline;vertical-align:middle;"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
删除
</button>` : ''}
${currentUser ? `<button class="btn-sm btn-secondary" id="detailReportBtn" data-postid="${post.id}" style="padding:4px 10px;">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline;vertical-align:middle;"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="M12 8v4"/><path d="M12 16h.01"/></svg>
举报
</button>` : ''}
</div>
</div>
<div class="post-content" style="font-size:16px;line-height:1.8;">${renderedContent}</div>
@@ -192,6 +196,16 @@ async function renderPostDetail(postId) {
});
}
// 举报按钮:原先只在列表卡片上,现移到详情页。
// 提交逻辑在 app.js 中读取 reportTargetPostId,这里只负责记录目标并打开弹窗。
const reportBtn = document.getElementById('detailReportBtn');
if (reportBtn) {
reportBtn.addEventListener('click', function() {
reportTargetPostId = this.dataset.postid;
document.getElementById('reportModal').classList.add('active');
});
}
document.querySelectorAll('.reply-delete-btn').forEach(btn => {
btn.addEventListener('click', async function(e) {
e.stopPropagation();