4.B 分享按页面 mode 拆分:大厅直发微信 3 分支 / 子游戏 SharePanel
【契约影响】docs/H5-Native-Contract.md §3.1[2]
原 msext 把 friendsSharetypeUrlToptitleDescript 同名 handler 在两个 VC
各注册一份且**行为完全不同**:
- NewRootVC.m(大厅):直发微信,3 type 分支
type==1 sendLinkURL(sharelogo 缩略图)
type==2 sendImageData(截图 40% 缩放为 thumb)
其他 NSData fromURL → sendImageData(公众号二维码场景)
- gameController.m(子游戏,活路径,早 return):
sharefriend==1 SharePanel 三选一
其他 WechatShareManager 朋友圈兜底(2 分支:截图/链接)
先前新外壳两个 VC 都注册同一份 handler 走"子游戏"逻辑,导致大厅页:
1. 强行弹 SharePanel 多一步操作
2. 丢失"远端图"分支(公众号二维码被错当链接发)
按页面 mode 拆开:
- FriendsShareHandler 加 Mode { lobby, subGame } 参数
- ShareCenter 拆 dispatchLobby(直发微信)/ dispatchSubGame(SharePanel)
- WechatShare 加 shareLobby() 实现完整 3 type 分支:
type==1 → shareLink + mediaTagName "游戏下载链接" + appIcon thumb
(原 msext 用 sharelogo.png,按用户决定 fallback 到 app icon)
type==2 → shareImage + mediaTagName "游戏截图分享" + 截图 0.4x thumb
+ messageExt = H5 description
其他 → URLSession 下载 NSData 直发 + 远端图 0.4x thumb
+ mediaTagName/messageExt 固定字面"公众号二维码分享"
- WebContainerViewController 注册 .lobby;SubGameViewController .subGame
附带修 sharefriend 默认值:之前 ?? "1"(弹面板)与原 msext nil→[intValue]
==0→朋友圈微信不一致。改成 ?? "",由 ShareCenter default 分支兜底走
朋友圈微信,与原项目完全等价。
This commit is contained in:
@@ -2,9 +2,17 @@
|
||||
// ShareCenter.swift
|
||||
// ylgamehall
|
||||
//
|
||||
// H5 friendsShare 调用入口的协调中心,按 msext gameController.m:575-597 行为:
|
||||
// - sharefriend == "1"(好友/私聊)→ 弹 SharePanel 三选一(微信/QQ/抖音)
|
||||
// - sharefriend == "2"(朋友圈) → 直接 WechatShare(朋友圈 timeline 场景)
|
||||
// H5 friendsShare 调用入口的协调中心。原 msext 同名 handler 在两个
|
||||
// ViewController 各注册一份且**行为不同**,新外壳按页面 mode 分发:
|
||||
//
|
||||
// • dispatchSubGame — 对齐 msext gameController.m:575-597(活路径):
|
||||
// - sharefriend == "1" → SharePanel 三选一(微信/QQ/抖音)
|
||||
// - 其他 → WechatShare.share() 朋友圈 timeline
|
||||
//
|
||||
// • dispatchLobby — 对齐 msext NewRootVC.m:453-537:直发微信,无 SharePanel
|
||||
// - sharefriend == "1" → WXSceneSession(好友)
|
||||
// - 其他 → WXSceneTimeline(朋友圈)
|
||||
// - type 3 分支由 WechatShare.shareLobby 内部处理
|
||||
//
|
||||
// fire-and-forget:H5 端 sharesuccess 已在 FriendsShareHandler 立即触发,
|
||||
// 这里只负责拉起 UI / SDK,不需要回传结果。
|
||||
@@ -15,19 +23,23 @@ import Foundation
|
||||
@MainActor
|
||||
public enum ShareCenter {
|
||||
|
||||
public static func dispatch(_ content: ShareContent) {
|
||||
/// 子游戏页(SubGameViewController)路径:SharePanel + 朋友圈兜底
|
||||
public static func dispatchSubGame(_ content: ShareContent) {
|
||||
switch content.sharefriend {
|
||||
case "1":
|
||||
// 好友/私聊 → SharePanel 三选一
|
||||
SharePanel.show(content: content)
|
||||
|
||||
case "2":
|
||||
// 朋友圈 → 直接 WechatShare(timeline 场景)
|
||||
WechatShare.shared.share(content, scene: .timeline)
|
||||
|
||||
default:
|
||||
// 未知 sharefriend:msext 沿用第二条分支兜底(朋友圈微信)
|
||||
// sharefriend == "2" 或缺失或其他 → msext WechatShareManager
|
||||
// 内部 [sharefriend intValue] != 1 → WXSceneTimeline 兜底
|
||||
WechatShare.shared.share(content, scene: .timeline)
|
||||
}
|
||||
}
|
||||
|
||||
/// 大厅页(WebContainerViewController)路径:直发微信,无 SharePanel
|
||||
public static func dispatchLobby(_ content: ShareContent) {
|
||||
let scene: ShareScene = content.sharefriend == "1" ? .friend : .timeline
|
||||
WechatShare.shared.shareLobby(content, scene: scene)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user