From 68e3d30f3f333da5b647fa96d3a4a4a5b10c7cd0 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Thu, 9 Apr 2026 00:31:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A9=BA=E5=86=85=E5=AE=B9=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=A1=AE=E8=AE=A4=20+=20=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 25 +++++++++++++++++++++++ templates/index.html | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/app.py b/app.py index 90c92ed..664ca26 100644 --- a/app.py +++ b/app.py @@ -182,6 +182,31 @@ def api_update_note(note_id): return jsonify(note) + +@app.route('/api/notes//rename', methods=['POST']) +def api_rename_note(note_id): + """重命名笔记标题""" + data = request.get_json() + new_title = data.get('title', '').strip() + + if not new_title: + return jsonify({'error': '标题不能为空'}), 400 + + notes = load_notes() + note = next((n for n in notes if n['id'] == note_id), None) + + if not note: + return jsonify({'error': 'Note not found'}), 404 + + note['title'] = new_title + note['updated_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + + # 重新排序 + notes = sorted(notes, key=lambda x: (not x.get('pinned', False), x.get('updated_at', '')), reverse=True) + save_notes(notes) + + return jsonify({'success': True, 'title': new_title, 'note': note}) + @app.route('/api/notes//title', methods=['POST']) def api_regenerate_title(note_id): """手动重新生成标题""" diff --git a/templates/index.html b/templates/index.html index 99bb401..82c646a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -151,6 +151,10 @@