启动文字提示,h5调试加入

This commit is contained in:
joywayer
2026-06-24 21:20:05 +08:00
parent 1d231a52ef
commit 06b7686e17
12 changed files with 70 additions and 29 deletions
@@ -5,7 +5,8 @@
// 监听 UIApplication 前/后台切换通知,提供 onBackground / onForeground 钩子。
//
// 契约:docs/H5-Native-Contract.md §3.2 [4]appservice 反向 callback
// "1" = 进入后台 / "2" = 回到前台(命名错位沿用历史)
// "2" = 进入后台 / "1" = 回到前台(值错位沿用历史 msext WKWebView 路径,
// 参 daoqi/msext NewRootVC.m:1773/1782、gameController.m:1323/1332)
// Phase 2.11
//
@@ -53,6 +53,11 @@ public final class BridgedWebView: UIView {
// ── 创建 WKWebView + BridgeBus ─────────────────────────
let webView = WKWebView(frame: .zero, configuration: configuration)
#if DEBUG
if #available(iOS 16.4, *) {
webView.isInspectable = true
}
#endif
let bridge = BridgeBus(webView: webView,
controller: configuration.userContentController)
@@ -108,6 +108,11 @@ public final class OverlayViewController: UIViewController {
}
webView = WKWebView(frame: .zero, configuration: config)
#if DEBUG
if #available(iOS 16.4, *) {
webView.isInspectable = true
}
#endif
webView.scrollView.bounces = false
webView.scrollView.contentInsetAdjustmentBehavior = .never
webView.translatesAutoresizingMaskIntoConstraints = false
@@ -43,7 +43,8 @@ final class SplashOverlay: UIView {
imageView.translatesAutoresizingMaskIntoConstraints = false
addSubview(imageView)
label.textColor = .white
// SplashImage 底部是白色留白,白字会完全融进去 → 用黑色。
label.textColor = .black
label.font = .systemFont(ofSize: 14, weight: .medium)
label.textAlignment = .center
label.numberOfLines = 1
@@ -336,11 +336,13 @@ public final class SubGameViewController: UIViewController {
bridge.call("getnetwork", data: .string("\(code)"), callback: nil)
}
// §3.2 [4] appservice — 值错位沿用历史 msext WKWebView 路径:
// 真·进入后台 → "2",真·回到前台 → "1"。参 WebContainerViewController 同位置注释。
AppLifecycleObserver.shared.onBackground = {
bridge.call("appservice", data: .string("1"), callback: nil)
bridge.call("appservice", data: .string("2"), callback: nil)
}
AppLifecycleObserver.shared.onForeground = {
bridge.call("appservice", data: .string("2"), callback: nil)
bridge.call("appservice", data: .string("1"), callback: nil)
}
// 电话状态 — 契约 §3.1 [14]:来电 "2" / 挂断 "0"
@@ -359,6 +359,12 @@ public final class WebContainerViewController: UIViewController {
throw BootError.ipaUpgradeRequired(downloadURL: dl)
}
// 过渡文案:config 已拉到、进入 zip 升级前的"建连等首字节"静默阶段。
// 不补这一步,用户会看到"拉取配置中..."一直显示到 zip CDN 冷 DNS+TLS 握完
// 才跳到"下载更新中 1%",慢网络下感知像卡死。这里把 UI 状态机补齐到与
// 实际工作阶段对应。
splash.update(text: "校验版本中...", progress: nil)
// H5 zip 升级失败仍致命(用户体验 ≠ 静默用旧 zip)—— 抛出由外层 splash.showError
// LobbyZipUpgrader.onProgress 由 URLSession delegate 后台队列调度,
// 必须显式 hop 到 MainActor 才能动 splash UI。
@@ -450,12 +456,15 @@ public final class WebContainerViewController: UIViewController {
bridge.call("getnetwork", data: .string("\(code)"), callback: nil)
}
// §3.2 [4] appservice — App 前后台切换(命名错位沿用历史)
// §3.2 [4] appservice — App 前后台切换(值错位沿用历史 msext WKWebView 路径)
// 真·进入后台 → "2",真·回到前台 → "1"。参 daoqi/msext NewRootVC.m:1773/1782、
// gameController.m:1323/1332(AppDelegate post 的 NSNotification 名也是错位的,
// 净结果是 H5 收到的桥值与"自然语义"相反,必须照抄)。
AppLifecycleObserver.shared.onBackground = {
bridge.call("appservice", data: .string("1"), callback: nil)
bridge.call("appservice", data: .string("2"), callback: nil)
}
AppLifecycleObserver.shared.onForeground = {
bridge.call("appservice", data: .string("2"), callback: nil)
bridge.call("appservice", data: .string("1"), callback: nil)
}
// §3.2 [12] getWebdata — 反向把 backgameData / 弹层 data 入参透传给大厅 H5。