From fa559101b90999b506be17f9e89d8c996fec0bd6 Mon Sep 17 00:00:00 2001 From: shenlei Date: Tue, 1 Sep 2026 11:02:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1=20S?= =?UTF-8?q?chema=20=E6=9C=AA=E6=9B=BF=E6=8D=A2=EF=BC=8C=E6=94=B9=E5=86=99?= =?UTF-8?q?=20CFBundleURLTypes=20=E4=B8=AD=20wxwork=20=E6=9D=A1=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前把 wxworkSchema 当成 Info.plist 顶层键写入,但真实 readoor31.plist 里企业微信 Schema 位于 CFBundleURLTypes(CFBundleURLName == "wxwork", 占位值 "1"),顶层键无效、占位符从未被替换。 改为并入 _update_plist 已有的 CFBundleURLTypes 替换逻辑:填写则替换 CFBundleURLSchemes,未配置则整条移除,与 weixinlogin/wechatpay/tencent 一致。 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01YZULZ8fkiaiJrxqf318xTn --- backend/services/project_patcher.py | 10 +++------- tests/test_project_patcher.py | 15 +++++++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/backend/services/project_patcher.py b/backend/services/project_patcher.py index d7f1684..840a7d2 100644 --- a/backend/services/project_patcher.py +++ b/backend/services/project_patcher.py @@ -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 = [] diff --git a/tests/test_project_patcher.py b/tests/test_project_patcher.py index 4145d1c..d6d8e31 100644 --- a/tests/test_project_patcher.py +++ b/tests/test_project_patcher.py @@ -33,7 +33,9 @@ def test_apply_project_config_without_branch_autopacking(tmp_path): "applinks:old\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)