From 15ea00fcd84f83f5b61cdbc941b2df0729470952 Mon Sep 17 00:00:00 2001 From: rockxsj Date: Thu, 19 Mar 2026 17:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/app.py | 11 +++++++++++ templates/accounts.html | 6 +++--- templates/email_services.html | 6 +++--- templates/index.html | 6 +++--- templates/login.html | 2 +- templates/payment.html | 6 +++--- templates/settings.html | 6 +++--- 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/web/app.py b/src/web/app.py index 52e02d4..3395bfb 100644 --- a/src/web/app.py +++ b/src/web/app.py @@ -36,6 +36,16 @@ STATIC_DIR = _RESOURCE_ROOT / "static" TEMPLATES_DIR = _RESOURCE_ROOT / "templates" +def _build_static_asset_version(static_dir: Path) -> str: + """基于静态文件最后修改时间生成版本号,避免部署后浏览器继续使用旧缓存。""" + latest_mtime = 0 + if static_dir.exists(): + for path in static_dir.rglob("*"): + if path.is_file(): + latest_mtime = max(latest_mtime, int(path.stat().st_mtime)) + return str(latest_mtime or 1) + + def create_app() -> FastAPI: """创建 FastAPI 应用实例""" settings = get_settings() @@ -80,6 +90,7 @@ def create_app() -> FastAPI: # 模板引擎 templates = Jinja2Templates(directory=str(TEMPLATES_DIR)) + templates.env.globals["static_version"] = _build_static_asset_version(STATIC_DIR) def _auth_token(password: str) -> str: secret = get_settings().webui_secret_key.get_secret_value().encode("utf-8") diff --git a/templates/accounts.html b/templates/accounts.html index efd1204..66d163d 100644 --- a/templates/accounts.html +++ b/templates/accounts.html @@ -4,7 +4,7 @@ 账号管理 - OpenAI 注册系统 - +