 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 |
|
 joywayerandClaude Opus 4.7
|
2ad4563d16
|
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>
|
2026-06-22 20:02:34 +08:00 |
|