fix: 点击未读数据后更新未读状态和类别计数
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user