diff --git a/app/admin_service.py b/app/admin_service.py index c461af9..9cd093a 100644 --- a/app/admin_service.py +++ b/app/admin_service.py @@ -79,18 +79,18 @@ def article(): "username": session.get("username"), } - - if request.method == "GET": - try: - delete_id = int(request.args.get("delete_id", 0)) - except: - return "Delete article ID must be integer!" - if delete_id: # delete article - delete_article_by_id(delete_id) - _update_context() - - elif request.method == "POST": + if request.method == "POST": data = request.form + + if "delete_id" in data: + try: + delete_id = int(data["delete_id"]) # 转成int型 + delete_article_by_id(delete_id) # 根据id删除article + flash(f'Article ID {delete_id} deleted successfully.') # 刷新页首提示语 + _update_context() + except ValueError: + flash('Invalid article ID for deletion.') + content = data.get("content", "") source = data.get("source", "") question = data.get("question", "") diff --git a/app/templates/admin_manage_article.html b/app/templates/admin_manage_article.html index 272b54e..5849e10 100644 --- a/app/templates/admin_manage_article.html +++ b/app/templates/admin_manage_article.html @@ -7,6 +7,11 @@ content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" /> + @@ -66,9 +71,10 @@
{% for text in text_list %}
-
- 删除 -
+
+ + +
{{ text.title }}