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:
joywayer
2026-06-24 08:19:21 +08:00
parent 68c668a06c
commit 5d4bdc2e29
5 changed files with 125 additions and 28 deletions
+21 -9
View File
@@ -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-forgetH5 sharesuccess FriendsShareHandler
// UI / SDK
@@ -15,19 +23,23 @@ import Foundation
@MainActor
public enum ShareCenter {
public static func dispatch(_ content: ShareContent) {
/// SubGameViewControllerSharePanel +
public static func dispatchSubGame(_ content: ShareContent) {
switch content.sharefriend {
case "1":
// / SharePanel
SharePanel.show(content: content)
case "2":
// WechatSharetimeline
WechatShare.shared.share(content, scene: .timeline)
default:
// sharefriendmsext 沿
// 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)
}
}