From c681560f73abb0e57d3c53f0c7f86fa4276512ae Mon Sep 17 00:00:00 2001
From: DengDai <29502593+zzhhxx@users.noreply.github.com>
Date: Fri, 28 Nov 2025 09:08:53 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/__init__.py | 3 ++-
app/filters.py | 7 +++++++
app/templates/admin/appeal_list.html | 2 +-
app/templates/admin/manage_users.html | 2 +-
app/templates/admin/pending_users.html | 2 +-
app/templates/admin/report_detail.html | 4 ++--
app/templates/admin/report_list.html | 2 +-
app/templates/appeal_detail.html | 6 +++---
app/templates/index.html | 2 +-
app/templates/my_appeals.html | 4 ++--
app/templates/my_reports.html | 2 +-
11 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/app/__init__.py b/app/__init__.py
index 1c4f8d4..0120dc5 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -61,10 +61,11 @@ def create_app(config_name='default'):
app.logger.info('PT黑名单系统启动')
# 注册自定义过滤器
- from .filters import translate_status, translate_reason, translate_reasons_list
+ from .filters import translate_status, translate_reason, translate_reasons_list, to_beijing_time
app.jinja_env.filters['translate_status'] = translate_status
app.jinja_env.filters['translate_reason'] = translate_reason
app.jinja_env.filters['translate_reasons_list'] = translate_reasons_list
+ app.jinja_env.filters['to_beijing_time'] = to_beijing_time
# 注册蓝图
from .routes import main as main_blueprint
diff --git a/app/filters.py b/app/filters.py
index 417a63d..02c1e12 100644
--- a/app/filters.py
+++ b/app/filters.py
@@ -1,4 +1,5 @@
"""Jinja2模板过滤器"""
+from datetime import timedelta
STATUS_TRANSLATIONS = {
'pending': '待审核',
@@ -45,3 +46,9 @@ def translate_reasons_list(reasons):
if not reasons:
return []
return [REASON_TRANSLATIONS.get(r, r) for r in reasons]
+
+def to_beijing_time(utc_dt):
+ """UTC时间转北京时间(UTC+8)"""
+ if utc_dt is None:
+ return None
+ return utc_dt + timedelta(hours=8)
diff --git a/app/templates/admin/appeal_list.html b/app/templates/admin/appeal_list.html
index 3799f8c..bc66899 100644
--- a/app/templates/admin/appeal_list.html
+++ b/app/templates/admin/appeal_list.html
@@ -34,7 +34,7 @@
{{ appeal.status | translate_status }}
-
{{ appeal.updated_at.strftime('%Y-%m-%d %H:%M') }} |
+ {{ (appeal.updated_at | to_beijing_time).strftime('%Y-%m-%d %H:%M') }} |
查看详情
|
diff --git a/app/templates/admin/manage_users.html b/app/templates/admin/manage_users.html
index 1410a51..5c26e6b 100644
--- a/app/templates/admin/manage_users.html
+++ b/app/templates/admin/manage_users.html
@@ -30,7 +30,7 @@
{{ user.email }}
{{ user.pt_site }} / {{ user.uid }} |
- {{ user.created_at.strftime('%Y-%m-%d') }} |
+ {{ (user.created_at | to_beijing_time).strftime('%Y-%m-%d') }} |
{% if user.id == 1 %}
角色: {{ user.role }}
diff --git a/app/templates/admin/pending_users.html b/app/templates/admin/pending_users.html
index 8e923ee..a021afc 100644
--- a/app/templates/admin/pending_users.html
+++ b/app/templates/admin/pending_users.html
@@ -27,7 +27,7 @@
| {{ user.email }} |
{{ user.pt_site }} |
{{ user.uid }} |
- {{ user.created_at.strftime('%Y-%m-%d %H:%M') }} |
+ {{ (user.created_at | to_beijing_time).strftime('%Y-%m-%d %H:%M') }} |
|
{{ report.reporter.username }} |
{{ report.status | translate_status }} |
- {{ report.created_at.strftime('%Y-%m-%d %H:%M') }} |
+ {{ (report.created_at | to_beijing_time).strftime('%Y-%m-%d %H:%M') }} |
查看详情 |
{% else %}
diff --git a/app/templates/appeal_detail.html b/app/templates/appeal_detail.html
index d6eddeb..8d77181 100644
--- a/app/templates/appeal_detail.html
+++ b/app/templates/appeal_detail.html
@@ -68,7 +68,7 @@
[初始申诉理由]
@@ -82,10 +82,10 @@
diff --git a/app/templates/index.html b/app/templates/index.html
index 11b451b..b6b8964 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -57,7 +57,7 @@
未知
{% endif %}
-
记录时间: {{ search_result.created_at.strftime('%Y-%m-%d') }}
+
记录时间: {{ (search_result.created_at | to_beijing_time).strftime('%Y-%m-%d') }}
为保护隐私,仅展示必要的脱敏信息。具体违规描述不对外公开。
diff --git a/app/templates/my_appeals.html b/app/templates/my_appeals.html
index e87821c..d4ad319 100644
--- a/app/templates/my_appeals.html
+++ b/app/templates/my_appeals.html
@@ -31,8 +31,8 @@
{{ appeal.status | translate_status }}
-
{{ appeal.created_at.strftime('%Y-%m-%d %H:%M') }} |
-
{{ appeal.updated_at.strftime('%Y-%m-%d %H:%M') }} |
+
{{ (appeal.created_at | to_beijing_time).strftime('%Y-%m-%d %H:%M') }} |
+
{{ (appeal.updated_at | to_beijing_time).strftime('%Y-%m-%d %H:%M') }} |
查看详情
|
diff --git a/app/templates/my_reports.html b/app/templates/my_reports.html
index fb6828f..7d0b462 100644
--- a/app/templates/my_reports.html
+++ b/app/templates/my_reports.html
@@ -36,7 +36,7 @@
{{ report.status | translate_status }}
-
{{ report.created_at.strftime('%Y-%m-%d %H:%M') }} |
+
{{ (report.created_at | to_beijing_time).strftime('%Y-%m-%d %H:%M') }} |
查看详情
|