- 后端改为 config/app.json;pytest 使用 config/app.test.json 与 set_config_file,不再依赖环境变量;移除 pydantic-settings。 - 前端 API/WebSocket 由 config/webui.json 经 Vite define 注入。 - 代理分数按延迟与随机取用次数计算,新增 use_count 与 proxy_scoring;保存设置时同步调度器启停。 - 仪表盘双饼图(可用/待验证协议);设置页去掉调度器启停按钮并移动立即验证;爬取全部结束后自动提交全量验证。 - 删除 script/settings_maintain.py(此前已标记删除)。 Made-with: Cursor
25 lines
714 B
Python
25 lines
714 B
Python
"""配置文件路径解析(先于 config 加载,供测试在导入应用前切换配置文件)"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
_CONFIG_FILE: Optional[Path] = None
|
|
|
|
|
|
def project_root() -> Path:
|
|
"""项目根目录(含 config/、app/ 的目录)"""
|
|
return Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def set_config_file(path: Path) -> None:
|
|
"""指定使用的应用配置文件(仅测试应在导入 app.core.config 之前调用)"""
|
|
global _CONFIG_FILE
|
|
_CONFIG_FILE = Path(path)
|
|
|
|
|
|
def resolved_config_path() -> Path:
|
|
if _CONFIG_FILE is not None:
|
|
return _CONFIG_FILE
|
|
return project_root() / "config" / "app.json"
|