Files
youle_app_ios_v2/ylgamehall/Source/Share/ShareCenter.swift
T

55 lines
2.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// ShareCenter.swift
// ylgamehall
//
// H5 friendsShare 调用入口的协调中心。原 msext 同名 handler 在两个
// ViewController 各注册一份且**行为不同**,新外壳按页面 mode 分发:
//
// • dispatchSubGame — 对齐 msext gameController.m:575-597(活路径):
// - sharefriend == "1" 且 BundleConfig.isMultiShareEnabled
// → SharePanel 三选一(微信/QQ/抖音)
// - sharefriend == "1" 且 multishare 关闭
// → 直发微信好友(渠道级降级为单一平台)
// - 其他 → 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,不需要回传结果。
//
import Foundation
@MainActor
public enum ShareCenter {
/// 子游戏页(SubGameViewController)路径:SharePanel + 朋友圈兜底
public static func dispatchSubGame(_ content: ShareContent) {
switch content.sharefriend {
case "1":
// 好友/私聊:渠道级开关决定弹面板还是直发微信
if BundleConfig.shared.isMultiShareEnabled {
SharePanel.show(content: content)
} else {
// multishare = "0" → 三分享关闭,直接走微信好友(scene 参数在
// 剪贴板路径下用于文案 / 语义标注,不实际影响粘贴目标)
WechatShare.shared.share(content, scene: .friend)
}
default:
// 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)
}
}