fix: 点击未读数据后更新未读状态和类别计数

This commit is contained in:
2026-04-22 23:49:49 +08:00
parent 4b2a94002b
commit 70dee494f3

View File

@@ -3266,6 +3266,16 @@ async function showDetail(id, todoPage = 1, todoFilter = 'all') {
// 增加阅读数(首次加载时才增加)
if (todoPage === 1 && todoFilter === 'all') {
await fetch(`${API_BASE}/items/${id}/view`, { method: 'POST' });
// 更新当前数据的views移除未读标记
const itemIndex = currentItems.findIndex(i => i.id === id);
if (itemIndex >= 0 && (!currentItems[itemIndex].views || currentItems[itemIndex].views === 0)) {
currentItems[itemIndex].views = 1;
// 重新渲染列表
renderItems(currentItems);
// 更新统计
await loadStats();
}
}
const res = await fetch(`${API_BASE}/items/${id}`);