From 7074d84cbc1bd46e9bcacb312761f8f14145378f Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Thu, 4 Jun 2026 23:32:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=82=E8=80=83=E6=9D=A5?= =?UTF-8?q?=E6=BA=90JSON=E5=BA=8F=E5=88=97=E5=8C=96=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 手动将Reference对象转换为JSON字符串 - 避免使用tojson过滤器序列化SQLAlchemy对象 --- app/templates/admin/article_form.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/templates/admin/article_form.html b/app/templates/admin/article_form.html index c2f729b..6077a4c 100644 --- a/app/templates/admin/article_form.html +++ b/app/templates/admin/article_form.html @@ -350,7 +350,13 @@ function uploadImage(file, isPaste = false) { } // 参考来源管理 -let references = {% if references %}[{% for ref in references %}{"id": {{ ref.id }}, "title": "{{ ref.title }}", "url": "{{ ref.url or '' }}", "description": "{{ ref.description or '' }}"}{% if not loop.last %}, {% endif %}{% endfor %}]{% else %}[]{% endif %}; +let references = {% if references %}[ + {% for ref in references %} + {"id": {{ ref.id }}, "title": "{{ ref.title | e }}", "url": "{{ ref.url or '' | e }}", "description": "{{ ref.description or '' | e }}"} + {% if not loop.last %}, + {% endif %} + {% endfor %} +]{% else %}[]{% endif %}; function addReference() { references.push({id: null, title: '', url: '', description: ''}); @@ -425,7 +431,7 @@ function deleteAttachment(id) { {% block content %}
- +