fix: 企业微信 Schema 未替换,改写 CFBundleURLTypes 中 wxwork 条目
之前把 wxworkSchema 当成 Info.plist 顶层键写入,但真实 readoor31.plist 里企业微信 Schema 位于 CFBundleURLTypes(CFBundleURLName == "wxwork", 占位值 "1"),顶层键无效、占位符从未被替换。 改为并入 _update_plist 已有的 CFBundleURLTypes 替换逻辑:填写则替换 CFBundleURLSchemes,未配置则整条移除,与 weixinlogin/wechatpay/tencent 一致。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YZULZ8fkiaiJrxqf318xTn
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e10afb180d
commit
fa559101b9
@@ -36,18 +36,14 @@ def _update_plist(path: Path, config: dict):
|
||||
plist["CFBundleDisplayName"] = config.get("APPID_NAME", "")
|
||||
plist["AlivcLicenseKey"] = config.get("AlivcLicenseKey", "") or ""
|
||||
|
||||
# 企业微信 Schema:与微信登录 AppID 处理方式一致,未配置则移除该键。
|
||||
wxwork_schema = (config.get("wxworkSchema", "") or "").strip()
|
||||
if wxwork_schema:
|
||||
plist["wxworkSchema"] = wxwork_schema
|
||||
else:
|
||||
plist.pop("wxworkSchema", None)
|
||||
|
||||
scheme = (config.get("BUNDLE_ID", "") or "").replace(".", "").lower()
|
||||
values = {
|
||||
"weixinlogin": config.get("weixinlogin", ""),
|
||||
"wechatpay": config.get("weixinpay", ""),
|
||||
"tencent": config.get("tencent", ""),
|
||||
# 企业微信 Schema 与微信登录 AppID 同样存在 CFBundleURLTypes 中
|
||||
# (CFBundleURLName == "wxwork"),未配置则整条移除。
|
||||
"wxwork": (config.get("wxworkSchema", "") or "").strip(),
|
||||
"readoorUrlScheme": scheme,
|
||||
}
|
||||
url_types = []
|
||||
|
||||
@@ -33,7 +33,9 @@ def test_apply_project_config_without_branch_autopacking(tmp_path):
|
||||
"<string>applinks:old</string>\n", encoding="utf-8"
|
||||
)
|
||||
with (build_dir / "readoor" / "3.0" / "readoor31.plist").open("wb") as f:
|
||||
plistlib.dump({"CFBundleURLTypes": []}, f)
|
||||
plistlib.dump({"CFBundleURLTypes": [
|
||||
{"CFBundleURLName": "wxwork", "CFBundleURLSchemes": ["1"]},
|
||||
]}, f)
|
||||
|
||||
theme = tmp_path / "theme" / "AppIcon.appiconset"
|
||||
theme.mkdir(parents=True)
|
||||
@@ -60,7 +62,9 @@ def test_apply_project_config_without_branch_autopacking(tmp_path):
|
||||
assert (build_dir / "exportOptions.plist").exists()
|
||||
assert (logo / "icon-1024.png").read_bytes() == b"icon"
|
||||
with (build_dir / "readoor" / "3.0" / "readoor31.plist").open("rb") as f:
|
||||
assert plistlib.load(f)["wxworkSchema"] == "wx1234567890abcdef"
|
||||
url_types = plistlib.load(f)["CFBundleURLTypes"]
|
||||
wxwork = next(i for i in url_types if i["CFBundleURLName"] == "wxwork")
|
||||
assert wxwork["CFBundleURLSchemes"] == ["wx1234567890abcdef"]
|
||||
|
||||
|
||||
def _make_minimal_project(build_dir):
|
||||
@@ -91,7 +95,9 @@ def test_wxwork_schema_removed_when_not_configured(tmp_path):
|
||||
build_dir = tmp_path / "build"
|
||||
plist_path = _make_minimal_project(build_dir)
|
||||
with plist_path.open("wb") as f:
|
||||
plistlib.dump({"CFBundleURLTypes": [], "wxworkSchema": "stale-value"}, f)
|
||||
plistlib.dump({"CFBundleURLTypes": [
|
||||
{"CFBundleURLName": "wxwork", "CFBundleURLSchemes": ["1"]},
|
||||
]}, f)
|
||||
|
||||
config = {
|
||||
"VERSION": "2.0.0", "BUILD_VERSION": "2.0.0.1", "APPID": "guid",
|
||||
@@ -103,4 +109,5 @@ def test_wxwork_schema_removed_when_not_configured(tmp_path):
|
||||
apply_project_config(build_dir, config)
|
||||
|
||||
with plist_path.open("rb") as f:
|
||||
assert "wxworkSchema" not in plistlib.load(f)
|
||||
url_types = plistlib.load(f)["CFBundleURLTypes"]
|
||||
assert all(i.get("CFBundleURLName") != "wxwork" for i in url_types)
|
||||
|
||||
Reference in New Issue
Block a user