feat: 强化打包配置与服务安全
This commit is contained in:
+20
-1
@@ -5,12 +5,31 @@ from .config import 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()
|
||||
return config.get("apps", {})
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user