Commit Graph
2 Commits
Author SHA1 Message Date
joywayerandClaude Opus 4.7 8e4c36d1c8 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>
2026-06-23 01:33:17 +08:00
joywayerandClaude Opus 4.7 39c1b5164d Phase 4.D:DouyinShare URL Scheme + Photos 真实落地(不依赖 SDK)
移植 msext DouyinShareManager.m:201-269 shareImageToDouyin 完整流程到 Swift。

新增基础设施(Phase 4.F 截图 / 远端图也共用):

Source/Share/ImageProvider.swift:
  - captureScreenshot() throws -> UIImage:UIGraphicsImageRenderer 截
    keyWindow(含状态栏 + letterbox 黑边 + WebView),与 msext
    FuncPublic.getImageWithFullScreenshot 等价
  - downloadRemote(_:) async throws -> UIImage:URLSession.data(from:)
    下载远端 URL → UIImage 解码
  - ImageProviderError 错误分类(noKeyWindow / downloadFailed / decodeFailed /
    badURL)

Source/Share/PhotoLibrarySaver.swift:
  - save(_:) async throws:使用 PHAccessLevel.addOnly(iOS 14+ 推荐,仅写
    相册不读,弹窗更友好)+ PHAssetChangeRequest.creationRequestForAsset
  - 自动处理权限三态(authorized/notDetermined 请求 + denied/restricted 抛错)

DouyinShare.share 完整实现:
  - 拿图片源:
    * type == "2" 截图 / type == "1" 链接(退化为当前屏截屏,msext 行为)
      → ImageProvider.captureScreenshot
    * type == 其它(远端图 URL)→ ImageProvider.downloadRemote(webpageUrl)
  - PhotoLibrarySaver.save 保存到相册(含 .permissionDenied 错误回 .failed)
  - UIPasteboard.general.image = image 兜底(抖音可能从剪贴板读图)
  - 按 msext 顺序尝试 4 个 URL Scheme:
    snssdk1128://camera / publish / share/image / 基础 scheme
    canOpenURL 命中即 await UIApplication.open + 调起即 success
  - 全部失败返回 .failed("所有抖音 URL Scheme 都调起失败")

Info.plist 加 NSPhotoLibraryAddUsageDescription("需要将分享内容保存到
相册,以便您在抖音中选取分享"),addOnly 权限弹窗用此文案。

BuildProject 通过

Plan §5 Phase 4.4 勾选

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-22 20:07:45 +08:00