From 8c62c8121df4bd214a9acd78f787bf2092f7cbe7 Mon Sep 17 00:00:00 2001 From: snaily Date: Thu, 18 Sep 2025 06:29:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(static):=20=E5=AE=9E=E7=8E=B0=E9=9D=99?= =?UTF-8?q?=E6=80=81=E8=B5=84=E6=BA=90=E7=89=88=E6=9C=AC=E5=8C=96=E5=92=8C?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在Dockerfile中添加默认环境变量配置 - 新增静态资源URL版本化管理功能 - 更新所有模板文件使用static_url函数替代硬编码路径 - 优化错误日志页面移动端按钮布局和响应式设计 - 简化异常处理器返回格式 BREAKING CHANGE: 静态资源URL格式变更,需要重新部署以确保资源正确加载 --- Dockerfile | 3 + app/exception/exceptions.py | 9 +- app/router/routes.py | 3 + app/templates/auth.html | 2 +- app/templates/base.html | 8 +- app/templates/config_editor.html | 4 +- app/templates/error_logs.html | 183 ++++++++++++++++++++++++++++++- app/utils/static_version.py | 127 +++++++++++++++++++++ 8 files changed, 320 insertions(+), 19 deletions(-) create mode 100644 app/utils/static_version.py diff --git a/Dockerfile b/Dockerfile index 7ce4b5c..1c36481 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,9 @@ COPY ./VERSION /app RUN pip install --no-cache-dir -r requirements.txt COPY ./app /app/app +ENV API_KEYS='["your_api_key_1"]' +ENV ALLOWED_TOKENS='["your_token_1"]' +ENV TZ='Asia/Shanghai' # Expose port EXPOSE 8000 diff --git a/app/exception/exceptions.py b/app/exception/exceptions.py index b951c03..9c8f99a 100644 --- a/app/exception/exceptions.py +++ b/app/exception/exceptions.py @@ -130,11 +130,6 @@ def setup_exception_handlers(app: FastAPI) -> None: """处理通用异常""" logger.exception(f"Unhandled Exception: {str(exc)}") return JSONResponse( - status_code=exc.args[0], - content={ - "error": { - "code": exc.args[0], - "message": exc.args[1], - } - }, + status_code=500, + content=str(exc), ) diff --git a/app/router/routes.py b/app/router/routes.py index 03848f6..4ba4865 100644 --- a/app/router/routes.py +++ b/app/router/routes.py @@ -24,10 +24,13 @@ from app.router import ( ) from app.service.key.key_manager import get_key_manager_instance from app.service.stats.stats_service import StatsService +from app.utils.static_version import get_static_url logger = get_routes_logger() templates = Jinja2Templates(directory="app/templates") +# 设置模板全局变量 +templates.env.globals["static_url"] = get_static_url def setup_routers(app: FastAPI) -> None: diff --git a/app/templates/auth.html b/app/templates/auth.html index efebedf..9e1d058 100644 --- a/app/templates/auth.html +++ b/app/templates/auth.html @@ -51,7 +51,7 @@

- Gemini Balance Logo + Gemini Balance Logo Gemini Balance

diff --git a/app/templates/base.html b/app/templates/base.html index 6ba6ccc..e4ed1f3 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -4,21 +4,21 @@ {% block title %}Gemini Balance{% endblock %} - + - + - + + +