From 6b775c99f98d7c49066d041fa4c1b77b3b8439c2 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Thu, 16 Apr 2026 11:05:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=B2=E5=AE=8C=E6=88=90=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E5=8F=AF=E9=87=8D=E6=96=B0=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 /api/items//reopen 接口 - 前端列表已完成待办显示重新打开按钮 - 恢复为 pending 或 in_progress 状态 --- xian_favor/api.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/xian_favor/api.py b/xian_favor/api.py index 044d8e7..4ef9561 100644 --- a/xian_favor/api.py +++ b/xian_favor/api.py @@ -112,6 +112,28 @@ def complete_item(item_id): return jsonify({'success': True, 'data': item}) +@app.route('/api/items//reopen', methods=['POST']) +def reopen_item(item_id): + """重新打开待办""" + item = db.get_item(item_id) + if not item: + return jsonify({'success': False, 'error': '条目不存在'}), 404 + + if item['type'] != 'todo': + return jsonify({'success': False, 'error': '不是待办事项'}), 400 + + # 获取请求中的目标状态,默认为 pending + data = request.get_json() or {} + new_status = data.get('status', 'pending') + + if new_status not in ['pending', 'in_progress']: + return jsonify({'success': False, 'error': '无效状态'}), 400 + + db.update_item(item_id, status=new_status) + item = db.get_item(item_id) + return jsonify({'success': True, 'data': item}) + + @app.route('/api/tags', methods=['GET']) def list_tags(): """列出标签""" @@ -1017,8 +1039,9 @@ function renderItems(items) {
-
+
${getTypeIcon(item.type)} ${item.title || truncate(item.content || item.url, 30)} + ${item.type === 'todo' && item.status === 'completed' ? ' ✓' : ''}

${item.url ? truncate(item.url, 50) : item.content ? truncate(item.content, 50) : item.note ? truncate(item.note, 50) : ''} @@ -1030,6 +1053,7 @@ function renderItems(items) { ${item.type === 'todo' && item.status !== 'completed' ? `` : ''} + ${item.type === 'todo' && item.status === 'completed' ? `` : ''}

@@ -1138,6 +1162,20 @@ async function completeItem(id) { refreshData(); } +// 重新打开待办 +async function reopenItem(id) { + const res = await fetch(`${API_BASE}/items/${id}/reopen`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ status: 'pending' }) + }); + + if (res.ok) { + refreshData(); + loadReminders(); // 刷新提醒 + } +} + // 删除条目 async function deleteItem(id) { if (!confirm('确认删除?')) return;