mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 12:52:26 +00:00
refactor(test, config, router): 整理代码结构与配置,优化导入顺序
1. 调整多个测试文件中TestClient的导入顺序,统一放到conftest导入之后 2. 删除后端配置中无用的WebSocket限流配置,统一使用全局200次/10秒的限流策略 3. 精简平台、系统模块的路由初始化注释文档 4. 优化conftest.py中的数据库初始化导入顺序 5. 调整初始化日志输出格式,更清晰易懂 6. 前端开发环境配置切回本地后端地址,注释远程服务地址 7. 重构路由类的变量命名,提升可读性 8. 简化动态路由热重载逻辑,移除冗余缓存变量 9. 重构注册路由的代码,统一限流配置,调整导入顺序和挂载逻辑 10. 删除冗余的v1接口层统一导出文件
This commit is contained in:
@@ -178,22 +178,14 @@ def reload_dynamic_router() -> APIRouter:
|
||||
# ── 2. 清除插件模块缓存,迫使 importlib 重新执行模块代码 ──
|
||||
_purge_plugin_modules()
|
||||
|
||||
# ── 3. 重新扫描并构建 ──
|
||||
_dynamic_router_cache = _build_dynamic_router()
|
||||
|
||||
# ── 4. 将新路由挂载回 app ──
|
||||
# ── 3. 将新路由挂载回 app ──
|
||||
if app:
|
||||
# 构造与 init_app.py 中相同的依赖项
|
||||
try:
|
||||
from fastapi_limiter.depends import RateLimiter
|
||||
rate_deps = [Depends(RateLimiter(times=200, seconds=10))]
|
||||
except Exception:
|
||||
rate_deps = []
|
||||
app.include_router(_dynamic_router_cache, dependencies=rate_deps)
|
||||
app.include_router(_build_dynamic_router())
|
||||
logger.info("✅ 新插件路由已挂载到运行中的 app")
|
||||
|
||||
logger.info("✅ 插件动态路由热重载完成")
|
||||
return _dynamic_router_cache
|
||||
return _build_dynamic_router()
|
||||
|
||||
|
||||
def _purge_plugin_modules() -> None:
|
||||
|
||||
Reference in New Issue
Block a user