添加multishare配置,用来开启关闭3分享

This commit is contained in:
joywayer
2026-07-03 22:20:48 +08:00
parent 113b4d4960
commit d76064c4c5
4 changed files with 45 additions and 16 deletions
+11 -8
View File
@@ -508,10 +508,10 @@ public enum OverlayBridge {
| getter | 返回类型 | 业务语义 | 数据源 |
|---|---|---|---|
| `getchannelName()` | string | 渠道 ID10 项渠道注入之一)| `BundleConfig.shared.channel` |
| `getmarketname()` | string | 市场 ID10 项渠道注入之一)| `BundleConfig.shared.market` |
| `getchannelName()` | string | 渠道 ID11 项渠道注入之一)| `BundleConfig.shared.channel` |
| `getmarketname()` | string | 市场 ID11 项渠道注入之一)| `BundleConfig.shared.market` |
| `getOther()` | string | 渠道 `other` 字段 | `BundleConfig.shared.other` |
| `getothername(name)` | string | 按 H5 传入 key 动态读 10 项渠道注入任意字段 | `BundleConfig.shared.value(forKey: name)` |
| `getothername(name)` | string | 按 H5 传入 key 动态读 11 项渠道注入任意字段 | `BundleConfig.shared.value(forKey: name)` |
| `getcompareCode()` | int | 业务校验码(msext `RootVC.m` 沿用 zip 版本号或固定值) | 待原 msext 取值确认(Phase 2 实施时查 `RootVC.m:1560` 附近 `getcompareCode` 真实返回值,并对齐) |
| `getbattery()` | double | 当前电池电量 0.01.0 | `UIDevice.current.batteryLevel`(启动期 snapshot 一次) |
| `getnetwork()` | int | 当前网络类型(0 无 / 1 WiFi / 2 蜂窝) | `NWPathMonitor` 当前 pathloadFileURL 前 snapshot |
@@ -521,7 +521,7 @@ public enum OverlayBridge {
**为什么不走 BridgeBus 异步 callback**H5 端代码形式是 `var ch = window.settings.getchannelName()``var b = window.settings.getbattery()` 等**同步表达式**(取值后立即用于业务判断),WKWebView 时代 native 无法同步返回 JS 值(异步 evaluateJavaScript 改不了 H5 端代码 → 违反契约原则 A)。唯一不破契约的实现路径:**WebView 加载前在 `documentStart` 注入完整数据快照 + 同步 JS getter polyfill**,本地查询零延迟。
**数据快照时机**
- 静态字段(渠道 / market / other / appVersion 等 10 项渠道注入):app 启动期读 `ChannelConfig.plist` 后即不变,全程一次即可
- 静态字段(渠道 / market / other / appVersion 等 11 项渠道注入):app 启动期读 `ChannelConfig.plist` 后即不变,全程一次即可
- 动态字段(getbattery / getnetwork):**每次 `loadFileURL` 前重新 snapshot 注入**(精度足够,原 msext 自身也只在 `viewDidLoad` 取一次,H5 业务里"启动时刻电量值"被复用整个会话)
- 已安装子游戏列表(getGameinstall):每次 loadFileURL 前扫描沙盒 + 注入 → SwitchOverGameData 解压新子游戏后自然在下次 loadFileURL 刷新
@@ -552,7 +552,7 @@ public enum SettingsBridgePolyfill {
window.__nativeSnapshot = \(json);
window.settings = window.settings || {};
// ── 10 项渠道注入(静态,启动期一次性快照)────────────
// ── 11 项渠道注入(静态,启动期一次性快照)────────────
window.settings.getchannelName = function() { return window.__nativeSnapshot.channel || ""; };
window.settings.getmarketname = function() { return window.__nativeSnapshot.market || ""; };
window.settings.getOther = function() { return window.__nativeSnapshot.other || ""; };
@@ -583,7 +583,7 @@ public enum SettingsBridgePolyfill {
}
public struct Snapshot: Sendable {
public let channelConfig: [String: String] // 10
public let channelConfig: [String: String] // 11
public let channel: String
public let market: String
public let other: String
@@ -1818,9 +1818,11 @@ Phase 6 子游戏(`SwitchOverGameData` 入参的 `Gamedirectory` / `gamedownlo
**契约 §0.3 描述 msext 用"空目录名注入"机制存储 11 个渠道值,本项目按 ADR-007 改用 `ChannelConfig.plist` 等价实现** —— 契约边界(H5 通过 `app_data.js` 看到的 JS 全局变量)完全不变,实现内部更简洁。
> **2026-06-27 修订(ADR-009)**:原 11 个 key 之一的 `qiniudomain` 已移除 —— 七牛 CDN 域名改由 RemoteConfig 顶层 `audio_domain` 远端动态下发,跨渠道无差异化诉求。**当前 ChannelConfig.plist = 10 个 string key**。
> **2026-06-27 修订(ADR-009)**:原 11 个 key 之一的 `qiniudomain` 已移除 —— 七牛 CDN 域名改由 RemoteConfig 顶层 `audio_domain` 远端动态下发,跨渠道无差异化诉求。
>
> **2026-07-03 修订**:新增 `multishare` 字段,控制子游戏 sharefriend=1 好友分享形态("1" = SharePanel 三选一 / "0" = 仅微信直发)。**当前 ChannelConfig.plist = 11 个 string key**。
**存储**:`ylgamehall/Resources/ChannelConfig.plist`,10 个 string key 一一对应渠道值:
**存储**:`ylgamehall/Resources/ChannelConfig.plist`,11 个 string key 一一对应渠道值:
```xml
<dict>
@@ -1834,6 +1836,7 @@ Phase 6 子游戏(`SwitchOverGameData` 入参的 `Gamedirectory` / `gamedownlo
<key>appversion</key> <string>43</string>
<key>other</key> <string></string>
<key>appleconfig</key> <string></string>
<key>multishare</key> <string>1</string>
</dict>
```
+3 -1
View File
@@ -11,7 +11,7 @@
<key>gamestart</key>
<string>gamehall</string>
<key>gameconfig</key>
<string>tsgames.daoqi88.cn-config_test-update_jsonv2_test</string>
<string>tsgames.daoqi88.cn-config-update_jsonv2</string>
<key>market</key>
<string>2</string>
<key>agent</key>
@@ -22,5 +22,7 @@
<string></string>
<key>appleconfig</key>
<string></string>
<key>multishare</key>
<string>0</string>
</dict>
</plist>
+19 -4
View File
@@ -2,16 +2,19 @@
// BundleConfig.swift
// ylgamehall
//
// Bundle ChannelConfig.plist 10 string
// Bundle ChannelConfig.plist 11 string
// docs/H5-Native-Implementation-Design.md §7 / ADR-007
//
// qiniudomain 2026-06-27 CDN
// RemoteConfig audio_domain
//
// - qiniudomain 2026-06-27 CDN
// RemoteConfig audio_domain
// - multishare sharefriend=1
// ("1" = SharePanel / "0" = )
//
import Foundation
/// 10 `BundleConfig.shared` App
/// 11 `BundleConfig.shared` App
///
/// `plutil` `.app/ChannelConfig.plist` +
/// Xcode build ADR-007
@@ -30,6 +33,17 @@ nonisolated public final class BundleConfig: Sendable {
public let appVersion: String
public let other: String
public let appleConfig: String
/// sharefriend=1
/// "1" SharePanel / QQ /
/// "0"
/// "1"
public let multiShare: String
/// SharePanel `multiShare != "0"`
/// /
public var isMultiShareEnabled: Bool {
multiShare != "0"
}
/// bundle plist fixture
public init(bundle: Bundle = .main) {
@@ -44,6 +58,7 @@ nonisolated public final class BundleConfig: Sendable {
appVersion = dict["appversion"] ?? ""
other = dict["other"] ?? ""
appleConfig = dict["appleconfig"] ?? ""
multiShare = dict["multishare"] ?? ""
}
private static func loadPlist(bundle: Bundle) -> [String: String] {
+12 -3
View File
@@ -6,7 +6,10 @@
// ViewController **** mode
//
// dispatchSubGame msext gameController.m:575-597
// - sharefriend == "1" SharePanel /QQ/
// - sharefriend == "1" BundleConfig.isMultiShareEnabled
// SharePanel /QQ/
// - sharefriend == "1" multishare
//
// - WechatShare.share() timeline
//
// dispatchLobby msext NewRootVC.m:453-537 SharePanel
@@ -27,8 +30,14 @@ public enum ShareCenter {
public static func dispatchSubGame(_ content: ShareContent) {
switch content.sharefriend {
case "1":
// / SharePanel
SharePanel.show(content: content)
// /
if BundleConfig.shared.isMultiShareEnabled {
SharePanel.show(content: content)
} else {
// multishare = "0" ,(scene
// / ,)
WechatShare.shared.share(content, scene: .friend)
}
default:
// sharefriend == "2" msext WechatShareManager