feat: 根据应用版本自动重置构建版本

This commit is contained in:
shenlei
2026-07-20 16:03:59 +09:00
parent 89fb633b00
commit 8747792a4b
5 changed files with 32 additions and 20 deletions
+10 -10
View File
@@ -2,6 +2,7 @@
import asyncio
import json
import os
import re
import shutil
import zipfile
from datetime import datetime
@@ -501,19 +502,18 @@ async def get_versions():
@router.put("/versions")
async def update_versions(data: dict):
"""更新 App_Ver Build_Ver"""
"""更新 App_Ver,并将 Build_Ver 重置为对应的 .0。"""
app_ver = data.get("app_ver", "").strip()
build_ver = data.get("build_ver", "").strip()
if not re.fullmatch(r"\d+\.\d+\.\d+", app_ver):
raise HTTPException(status_code=400, detail="App_Ver 必须为主版本.次版本.修订号,例如 2.196.0")
if not app_ver or not build_ver:
raise HTTPException(status_code=400, detail="版本号不能为空")
config = load_config()
config["versions"] = {
"app_ver": app_ver,
"build_ver": build_ver,
}
build_ver = f"{app_ver}.0"
async with _config_lock:
config = load_config()
config["versions"] = {
"app_ver": app_ver,
"build_ver": build_ver,
}
save_config(config)
return {"message": "版本号已更新", "app_ver": app_ver, "build_ver": build_ver}