Phase 4.B:SharePlatform 框架 + SharePanel 三选一 UI + ShareCenter 分发

按 msext gameController.m:575-597 / SharePanel.m 模式落地分享框架。

新增 Source/Share/:
  - SharePlatform.swift:
    * SharePlatform 协议(name / isInstalled / share async → ShareResult)
    * ShareContent struct(nonisolated Sendable,6 字段 sharefriend/sharetype/
      type/webpageUrl/title/desc)
    * ShareResult enum (success / cancelled / notInstalled / failed)
    * ShareScene enum (friend / timeline)
  - SharePanel.swift:
    * @MainActor UIView,半透明黑底覆盖全屏 + 底部圆角内容视图滑入
    * 三按钮(微信绿 / QQ 蓝 / 抖音黑)+ label 等间距居中布局
    * 已安装平台按钮高亮,未装置灰
    * 点击空白区 dismiss + completion(.cancelled)
    * 点击按钮 dismiss + 触发对应 SharePlatform.share + completion(result)
    * 0.25s 滑入/滑出动画
    * 与 msext SharePanel.m 等价行为
  - ShareCenter.swift:
    * sharefriend == "1" → SharePanel.show 三选一
    * sharefriend == "2" → WechatShare.share scene: .timeline 朋友圈
    * 与 msext gameController.m:585 行为 1:1
  - WechatShare.swift:stub(Phase 4.E 等微信 SDK 接入)
  - QQShare.swift:stub + canOpenURL("mqqapi://") 检测(Phase 4.C 升级
    URL Scheme 真实调起)
  - DouyinShare.swift:stub + canOpenURL("snssdk1128://") 检测(Phase 4.D 升级
    URL Scheme + Photos)

FriendsShareHandler 升级:
  - 入参解析为 ShareContent
  - 调 ShareCenter.dispatch
  - completion 内根据 result 触发 sharesuccess 反向 callback:
    * success / cancelled → bridge.call("sharesuccess", {success:"2", type:sharefriend})
    * notInstalled / failed → 不发(H5 业务期 timeout 后自行 fallback,msext 乐观策略)

ShareContent 标 nonisolated 解 Swift 6 actor 隔离(项目默认 MainActor isolation
让 struct 跨 actor 受限)。

BuildProject 通过

Plan §5 Phase 4.2 勾选

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
joywayer
2026-06-22 20:02:34 +08:00
co-authored by Claude Opus 4.7
parent b071ced657
commit 2ad4563d16
8 changed files with 436 additions and 23 deletions
+7 -6
View File
@@ -479,12 +479,13 @@ Contract Design Plan(本文档)
- [ ] **4.1** `Vendor/WechatSDK/` 拷贝微信 SDK
- Info.plist 加 URL Scheme`wx586a9b321e56efb7`+ `LSApplicationQueriesSchemes``weixin` / `weixinULAPI` / `weixinURLParamsAPI`
- Entitlement 加 Associated DomainsUniversal Links
- [ ] **4.2** **SharePanel 三选一面板msext gameController.m:585 等价行为)**
- **关键发现**msext `gameController.m:575-597` 表明 H5 调 `friendsShare` 时:
- `sharefriend == 1`(好友/私聊)→ 弹 **SharePanel 三选一面板**(微信好友 + QQ + 抖音)
- `sharefriend == 2`(朋友圈)→ 直接 `WechatShareManager.shareWithContent`(朋友圈)
- Contract §3.1 2]旧描述(sharetype=3 闲聊)已被 msext 新代码覆盖;`sharetype` 字段在新代码里读了但不用
- 新外壳按 SharePanel 模式实现,不依赖 Contract 旧描述
- [x] **4.2** **SharePanel 三选一面板 + SharePlatform 框架**4.B 完成)
- `Source/Share/SharePlatform.swift`SharePlatform 协议(name / isInstalled / share async+ ShareContent structnonisolated Sendable+ ShareResult enumsuccess / cancelled / notInstalled / failed+ ShareScene enumfriend / timeline
- `Source/Share/SharePanel.swift`:底部弹出三按钮(微信 / QQ / 抖音)+ 半透明背景点击关闭 + 0.25s 滑入/滑出动画;与 msext SharePanel.m 等价行为
- `Source/Share/ShareCenter.swift`sharefriend == "1" 弹 SharePanel"2" 直接 WechatShare.timeline;与 msext gameController.m:585 行为 1:1
- `Source/Share/{Wechat,QQ,Douyin}Share.swift`:三个平台 stub(仅返回 success),Phase 4.C/4.D/4.E 升级
- `FriendsShareHandler` 升级:调 ShareCenter.dispatch + 完成后触发 sharesuccess 反向 callbacksuccess/cancelled 都发,notInstalled/failed 不发,沿用 msext 乐观策略)
- BuildProject 通过
- [ ] **4.3** **QQ 分享走 URL Scheme,不依赖 SDK**
- 移植 msext `QQShareManager.m:716-771` `simpleShareToQQFriend` 简化版
- URL 构造:`mqqapi://share/to_fri?version=1&cflag=0&req_type=1&url=...&title=...&description=...`