From 8e63db442471a3c69a8500ce2ae1403727a002da Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Wed, 22 Apr 2026 15:54:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(v4.1.1):=20=E5=BE=85=E5=8A=9E=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复完成状态切换问题(可来回切换完成/未完成) - 添加全部/未完成/已完成过滤按钮 - 翻页时保持弹窗滚动位置 --- xian_favor/api.py | 96 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 22 deletions(-) diff --git a/xian_favor/api.py b/xian_favor/api.py index aef452b..a61c099 100644 --- a/xian_favor/api.py +++ b/xian_favor/api.py @@ -2846,11 +2846,19 @@ async function deleteItem(id) { let currentDetailId = null; // 显示详情 -async function showDetail(id, todoPage = 1) { +async function showDetail(id, todoPage = 1, todoFilter = 'all') { currentDetailId = id; + currentTodoPage = todoPage; + currentTodoFilter = todoFilter; - // 增加阅读数 - await fetch(`${API_BASE}/items/${id}/view`, { method: 'POST' }); + // 记录当前弹窗滚动位置 + const detailContent = document.getElementById('detailContent'); + const scrollTop = detailContent.scrollTop; + + // 增加阅读数(首次加载时才增加) + if (todoPage === 1 && todoFilter === 'all') { + await fetch(`${API_BASE}/items/${id}/view`, { method: 'POST' }); + } const res = await fetch(`${API_BASE}/items/${id}`); const data = await res.json(); @@ -2915,21 +2923,46 @@ async function showDetail(id, todoPage = 1) { // 文本类型显示待办事务 if (item.type === 'text') { const todoOffset = (todoPage - 1) * 10; - const todoRes = await fetch(`${API_BASE}/items/${id}/todo-events?limit=10&offset=${todoOffset}`); - const todoData = await todoRes.json(); + + // 根据过滤状态获取数据 + let todoRes = await fetch(`${API_BASE}/items/${id}/todo-events?limit=10&offset=${todoOffset}`); + let todoData = await todoRes.json(); + + // 客户端过滤(因为API返回全部数据) + let filteredEvents = todoData.data; + let totalTodo = todoData.total; + + if (todoFilter === 'completed') { + filteredEvents = filteredEvents.filter(e => e.is_completed); + // 需要重新计算总数 + const allRes = await fetch(`${API_BASE}/items/${id}/todo-events?limit=1000&offset=0`); + const allData = await allRes.json(); + totalTodo = allData.data.filter(e => e.is_completed).length; + } else if (todoFilter === 'pending') { + filteredEvents = filteredEvents.filter(e => !e.is_completed); + const allRes = await fetch(`${API_BASE}/items/${id}/todo-events?limit=1000&offset=0`); + const allData = await allRes.json(); + totalTodo = allData.data.filter(e => !e.is_completed).length; + } html += `