- 分支管理新增「分支 / Tag」类型选择,Tag 存于 config["tags"],与分支不可重名 - 每个 Tag 与分支一样拥有同名独立版本轨道,默认上架轨 - 打包页按「分支」「Tag」分组选择;任务新增 ref_type 字段记录引用类型 - Tag 打包时 fetch --tags --force 后以游离 HEAD 检出 refs/tags/<tag> - 历史记录与下载页按类型显示「分支」或「Tag」 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""打包选择 API"""
|
|
from fastapi import APIRouter
|
|
|
|
from .config import get_tags, load_config
|
|
|
|
router = APIRouter(prefix="/api", tags=["apps"])
|
|
|
|
# 每个 App 都只能使用明确允许的 Scheme。
|
|
_APP_SCHEME_RULES = {
|
|
"申学": ("readoorShenXue",),
|
|
"申学APP": ("readoorShenXue",),
|
|
"英汉大词典测试": ("readoorDict",),
|
|
"英汉大词典": ("readoorDict",),
|
|
}
|
|
_DEFAULT_SCHEME_NAMES = ("readoor31", "readoor31OtherPay")
|
|
|
|
|
|
def get_allowed_scheme_names(app: dict) -> tuple[str, ...]:
|
|
"""返回 App 可使用的 Scheme 名称。"""
|
|
return _APP_SCHEME_RULES.get(app.get("name", ""), _DEFAULT_SCHEME_NAMES)
|
|
|
|
|
|
@router.get("/apps")
|
|
async def get_apps_for_build():
|
|
"""获取 apps 列表(供打包选择)"""
|
|
config = load_config()
|
|
apps = {}
|
|
for app_id, app in config.get("apps", {}).items():
|
|
app_data = app.copy()
|
|
app_data["allowed_scheme_names"] = list(get_allowed_scheme_names(app))
|
|
apps[app_id] = app_data
|
|
return apps
|
|
|
|
|
|
@router.get("/schemes")
|
|
async def get_schemes_for_build():
|
|
"""获取 schemes 列表(供打包选择)"""
|
|
config = load_config()
|
|
return config.get("schemes", {})
|
|
|
|
|
|
@router.get("/branches")
|
|
async def get_branches_for_build():
|
|
"""获取分支列表(供打包选择)"""
|
|
config = load_config()
|
|
return config.get("branches", ["main"])
|
|
|
|
|
|
@router.get("/tags")
|
|
async def get_tags_for_build():
|
|
"""获取 Tag 列表(供打包选择)"""
|
|
return get_tags(load_config())
|