## 新增功能 - 文件管理模块:分类树 + 文件上传/下载/删除 - 文件上传支持拖拽(Dragger)+ 手动上传(customRequest 模式) ## 页面布局统一(参照评测执行页) - 仪表盘/评测对象/评测场景/评测报告 全部改为全高 flex 布局 - 统一内联页头样式(h2 + 竖线分隔 + 描述) - 表格撑满高度、overflow 处理 - 每页添加刷新按钮 ## Bug 修复 - 分类树操作按钮 hover 不可见(CSS 规则缺失) - 文件上传失败(multipart boundary 缺失) - LLM API 响应 content blocks 数组格式支持(_extract_content_from_api_response) - response_time_max_ms 被静默忽略(隐式规则传空 params) - 空 messages 导致 IndexError 崩溃 - poll_reply 异常中止整个 run(缺 try/catch) - engine finally 未关闭 session - 3 个页面 UTC 时间戳解析偏差 8 小时 ## 后端 - EvalEngine: poll_reply 异常保护、空 dialog 保护、session 关闭 - LLM API 响应解析支持 content-block-array 格式 - 隐式 response_time 规则正确传递 max_ms 参数 ## 前端 - api.ts: 移除手动 Content-Type(让浏览器自动添加 boundary) - Files.tsx: customRequest 替代 beforeUpload、布局优化 - index.css: 分类树 hover 规则 - Targets/Scenarios/Home/Reports: 全高布局改造 - 3 个页面时间戳改用 formatDateTime()(修复 UTC 偏差) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2.1 KiB
Python
Executable File
78 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Synchronize the frontend package.json version with pyproject.toml.
|
|
|
|
pyproject.toml is the single source of truth for the project version.
|
|
Run this script before building the frontend or deploying so the two
|
|
files never drift apart.
|
|
|
|
Usage:
|
|
scripts/sync_version.py # read pyproject, write package.json
|
|
scripts/sync_version.py --check # exit 1 if they already differ
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
PYPROJECT = ROOT / "pyproject.toml"
|
|
PACKAGE_JSON = ROOT / "frontend" / "web" / "package.json"
|
|
|
|
|
|
_VERSION_RE = re.compile(r'^version\s*=\s*"([^"]+)"', re.MULTILINE)
|
|
|
|
|
|
def read_pyproject_version() -> str:
|
|
text = PYPROJECT.read_text(encoding="utf-8")
|
|
match = _VERSION_RE.search(text)
|
|
if not match:
|
|
raise RuntimeError(f"could not find version= in {PYPROJECT}")
|
|
return match.group(1)
|
|
|
|
|
|
def write_package_json_version(version: str) -> bool:
|
|
"""Update package.json's version field. Returns True if changed."""
|
|
data = json.loads(PACKAGE_JSON.read_text(encoding="utf-8"))
|
|
old = data.get("version")
|
|
if old == version:
|
|
return False
|
|
data["version"] = version
|
|
PACKAGE_JSON.write_text(
|
|
json.dumps(data, indent=2, ensure_ascii=False) + "\n",
|
|
encoding="utf-8",
|
|
)
|
|
return True
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument(
|
|
"--check", action="store_true",
|
|
help="Exit with status 1 if versions already match (CI-friendly).",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
version = read_pyproject_version()
|
|
changed = write_package_json_version(version)
|
|
|
|
if args.check:
|
|
if changed:
|
|
print(f"OUT_OF_SYNC pyproject={version} package.json was different")
|
|
return 1
|
|
print(f"OK version={version}")
|
|
return 0
|
|
|
|
if changed:
|
|
print(f"synced package.json -> {version}")
|
|
else:
|
|
print(f"already in sync: {version}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|