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;