4.B 分享逻辑对齐 daoqi msext:调用即触发 sharesuccess
【契约影响】docs/H5-Native-Contract.md §3.1[2]/§3.2[11]
H5 端 sharesuccess 时机改为"调用 friendsShare handler 即立刻发",与
原 msext 行为等价(live path 完全不等 SDK / URL Scheme 回包)。用户
明示有意为之:URL Scheme + 剪贴板路径本就没有可靠回包,乐观策略避免
H5 业务卡住。
3 平台分支严格 1:1 对齐 daoqi msext:
WechatShare(对齐 WechatShareManager shareWithContent)
- type=="2" → 截图 JPEG 0.6 + sendImageData + app icon thumb
- else → 链接分享 sendLinkURL + app icon thumb
- 移除原"远端图"分支(原项目无此分支)
- 新增 appIconImage helper(读 Info.plist CFBundleIcons,对齐
[self getAppIconImage])
QQShare(对齐 QQShareManager shareWithContent + simpleShareToQQFriend)
- type=="2" → 截图 → UIPasteboard.image → 4 URL Scheme fallback
- else → mqqapi://share/to_{fri,qzone}?req_type=1&url=...
&title=...&description=...(webpageUrl 空时 req_type=0)
- 不依赖 QQ SDK(CLAUDE.md ADR-006)
DouyinShare(对齐 DouyinShareManager shareWithContent)
- type=="2" → 截图 → UIPasteboard.image → "立即打开抖音"引导框
- else → title+"\n\n"+desc → UIPasteboard.string → 引导框
双侧空时兜底 "来自进贤聚友棋牌的精彩内容分享"
- 放弃之前的"存相册 + 自动拉起"激进路径,回到原项目"用户主动点"路径
架构调整:
- SharePlatform.share 改 sync fire-and-forget(去 ShareResult 返回)
- ShareCenter.dispatch / SharePanel.show 去 completion 参数
- FriendsShareHandler:解析后先发 responseCallback("sharefriend")
与 sharesuccess({success:"2", type:<sharefriend>}),再异步 dispatch
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
// - sharefriend == "1"(好友/私聊)→ 弹 SharePanel 三选一(微信/QQ/抖音)
|
||||
// - sharefriend == "2"(朋友圈) → 直接 WechatShare(朋友圈 timeline 场景)
|
||||
//
|
||||
// 与 Design §8.2 ShareKit 一致:策略模式 + SharePlatform 协议。
|
||||
// fire-and-forget:H5 端 sharesuccess 已在 FriendsShareHandler 立即触发,
|
||||
// 这里只负责拉起 UI / SDK,不需要回传结果。
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -14,27 +15,19 @@ import Foundation
|
||||
@MainActor
|
||||
public enum ShareCenter {
|
||||
|
||||
/// 统一分发入口。由 FriendsShareHandler 在 handler 闭包内调用。
|
||||
/// completion 在分享结果回来后触发;UI 期间 await 暂停闭包但 cb 已先返回(msext 行为)。
|
||||
public static func dispatch(_ content: ShareContent, completion: @escaping (ShareResult) -> Void) {
|
||||
public static func dispatch(_ content: ShareContent) {
|
||||
switch content.sharefriend {
|
||||
case "1":
|
||||
// 好友/私聊 → SharePanel 三选一
|
||||
SharePanel.show(content: content, completion: completion)
|
||||
SharePanel.show(content: content)
|
||||
|
||||
case "2":
|
||||
// 朋友圈 → 直接 WechatShare(timeline 场景)
|
||||
Task { @MainActor in
|
||||
let result = await WechatShare.shared.share(content, scene: .timeline)
|
||||
completion(result)
|
||||
}
|
||||
WechatShare.shared.share(content, scene: .timeline)
|
||||
|
||||
default:
|
||||
// 未知 sharefriend:msext 沿用第二条分支兜底(朋友圈微信)
|
||||
Task { @MainActor in
|
||||
let result = await WechatShare.shared.share(content, scene: .timeline)
|
||||
completion(result)
|
||||
}
|
||||
WechatShare.shared.share(content, scene: .timeline)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user