diff --git a/backend/services/distribution.py b/backend/services/distribution.py index 4982189..fe90cae 100644 --- a/backend/services/distribution.py +++ b/backend/services/distribution.py @@ -4,6 +4,7 @@ import plistlib import posixpath import re import shutil +from html import escape from pathlib import Path from urllib.parse import quote, unquote, urlparse @@ -54,14 +55,139 @@ def _write_manifest(config: dict, manifest: Path, ipa_url: str): plistlib.dump(data, f) +DOWNLOAD_PAGE_TEMPLATE = """ + + + + + +{title} - 安装 + + + +
+

{title}

+

版本 {version}

+ 安装 App +
{meta}
+

请使用 iPhone 自带的 Safari 浏览器打开本页面安装。
+ 安装后如提示“未受信任的开发者”,请前往「设置 → 通用 → VPN 与设备管理」信任该描述文件。

+
+ + +""" + + def _write_download_page(config: dict, html: Path, manifest_url: str): - install_url = f"itms-services://?action=download-manifest&url={quote(manifest_url, safe=':/?=&') }" - title = config.get("APPID_NAME", "iOS App") + install_url = f"itms-services://?action=download-manifest&url={quote(manifest_url, safe=':/?=&')}" + title = config.get("APPID_NAME") or "iOS App" + meta_items = [ + ("构建版本", config.get("BUILD_VERSION", "")), + ("Bundle ID", config.get("BUNDLE_ID", "")), + ("分支", config.get("SOURCE_BRANCH", "")), + ] + meta = "".join( + f"
{escape(label)}
{escape(str(value))}
" + for label, value in meta_items + if value + ) html.write_text( - "" - f"{title}

{title}

" - f"

版本 {config.get('VERSION', '')}

安装 App" - "", + DOWNLOAD_PAGE_TEMPLATE.format( + title=escape(title), + version=escape(str(config.get("VERSION", ""))), + install_url=escape(install_url, quote=True), + meta=meta, + ), encoding="utf-8", )