Phase 4.F:微信截图分享 type=2 / 远端图分享 type=其它

按 msext gameController.m:637-678 字面行为,WechatShare 按 content.type
分发:
- type=1 → shareLink(已有)
- type=2 → captureScreenshot → JPEG 0.6 + thumb 0.4x → shareImage
- type=其它 → downloadRemote(URL) → JPEG 0.9 + thumb 0.4x → shareImage

新增:
- ImageProvider.scaledThumb(_:scale:):等价 msext FuncPublic
  imageByScalingAndCroppingForSize 0.4x 缩放;微信 SDK setThumbImage:
  内部再压到 32KB
- WeChatManager.ShareImage 结构 + shareImage(_:scene:) 异步包装
  (WXImageObject + WXMediaMessage.setThumbImage,FIFO 串行复用 sharePending)

契约:与 type=1 一致,调成功 → sharesuccess 反向 callback(success/cancelled
都发);errCode=-2 → cancelled;其它 errCode → failed。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
joywayer
2026-06-23 01:33:17 +08:00
co-authored by Claude Opus 4.7
parent d9d9554d9f
commit 8e4c36d1c8
3 changed files with 96 additions and 11 deletions
@@ -39,6 +39,22 @@ public enum ImageProvider {
}
}
/// 0.4x msext
/// `imageByScalingAndCroppingForSize:CGSizeMake(w*0.4, h*0.4)`
/// gameController.m:656 / 677 SDK `setThumbImage:`
/// 32KB 4K SDK
/// JPEG
public static func scaledThumb(_ image: UIImage, scale: CGFloat = 0.4) -> UIImage {
let target = CGSize(
width: max(1, image.size.width * scale),
height: max(1, image.size.height * scale)
)
let renderer = UIGraphicsImageRenderer(size: target)
return renderer.image { _ in
image.draw(in: CGRect(origin: .zero, size: target))
}
}
/// URL UIImage URLSession /
public static func downloadRemote(_ urlString: String) async throws -> UIImage {
guard let url = URL(string: urlString) else {