Phase 6 commit C:backgameData pop + getWebdata 反向 callback
- 新增 Source/Bridge/Handlers/BackGameDataHandler.swift(仅 SubGameViewController 注册):
- 调 AudioPlayer.stopAllBackground 停背景音
- AppCoordinator.popSubGame(returningData:) → popViewController + 发 .subGameDidReturn
- data 兼容 string / object(非字符串走 JSONSerialization 序列化透传)
- 字面 cb "backgameData"(msext gameController.m:691-709 等价,
WXApi 清理跳过 — 微信 SDK 待 Phase 4.E)
- AudioPlayer.stopAllBackground:无条件停背景音(msext 不看 type 直接 nil 行为)
- SubGameViewController.registerBridgeHandlers:挂上 BackGameDataHandler,
注释更新 exitRoom/getVideoinfo/createRoom 推迟到 Phase 8
- WebContainerViewController:在 setupExternalSubscriptions 挂 .subGameDidReturn
观察者 → bridge.call("getWebdata", .string(data)),teardown 时 removeObserver
(生命周期与 battery/network/appservice 同一对,子游戏栈顶时大厅已 teardown
避免双发)
- Plan §5.6.3 / 6.5 / 6.6 / §8 进度已勾选
至此 SwitchOverGameData → push 子游戏 → backgameData → pop + getWebdata
完整链路接通;子游戏视频房间(exitRoom/getVideoinfo/createRoom)留待 Phase 8。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
a9eaf86c63
commit
5f3a435180
@@ -589,11 +589,20 @@ Contract Design Plan(本文档)
|
||||
|
||||
- [x] **6.1** `Source/Coordinator/AppCoordinator.swift`:2s 节流(`lastSwitchAt`)+ 栈深约束(`viewControllers.count < 2`)+ `.subGameDidReturn` 通知名(Design §2.4.3)
|
||||
- [x] **6.2** `Source/WebView/SubGameViewController.swift`:与大厅同款 BridgedWebView + Splash + 16:9 letterbox + ExternalSubscriptions;`AppDataWriter(containerRole: .subGame)` 写 4 个 app_*.js;H5 未安装则抛 `SubGameBootError.subGameNotInstalled`(待 6.7 接入下载)
|
||||
- [ ] **6.3** `Source/Bridge/Handlers/SubGameHandlers.swift`:19 共享 + `backgameData` + 3 个视频房间 stub(commit C 接入 backgameData)
|
||||
- [x] **6.3** 子游戏 handler 注册(拆散到独立 enum,不抽 `SubGameHandlers` 聚合类):
|
||||
- 14 个与大厅共享 handler 直接复用各自 enum.register
|
||||
- 新增 `Source/Bridge/Handlers/BackGameDataHandler.swift`,仅 SubGameViewController 注册
|
||||
- exitRoom / getVideoinfo / createRoom 等视频房间 handler 留待 Phase 8
|
||||
- [x] **6.4** `SwitchOverGameData` handler(大厅 + 子游戏共用):解参 `Gamedirectory` / `gamedownloadurl` / `data` → `AppCoordinator.shared.showSubGame(...)`;节流 / 栈深守门移到 Coordinator,handler 始终回 cb `"SwitchOverGameData"`(msext NewRootVC.m:541-566 等价)
|
||||
- [x] **SceneDelegate**:以 `UINavigationController` 承载大厅,`AppCoordinator.shared.navigationController` 持引;导航栏隐藏 + 禁用边缘 pop 手势
|
||||
- [ ] **6.5** `backgameData` handler(仅子游戏注册):停 audio → 发 `.subGameDidReturn` 通知 → coordinator.popSubGame
|
||||
- [ ] **6.6** 大厅监听 `.subGameDidReturn` → `bridge.call("getWebdata", data)`
|
||||
- [x] **6.5** `backgameData` handler(仅子游戏 `BackGameDataHandler.swift` 注册):
|
||||
- `AudioPlayer.shared.stopAllBackground()`(新增方法,msext 无条件 stop+nil 行为等价)
|
||||
- `AppCoordinator.shared.popSubGame(returningData:)` → 内部 popViewController + 发 `.subGameDidReturn`
|
||||
- callback 字面 `"backgameData"`
|
||||
- data 入参兼容 string / object(非字符串走 JSONSerialization 透传)
|
||||
- [x] **6.6** 大厅监听 `.subGameDidReturn` → `bridge.call("getWebdata", data)`
|
||||
- 挂钩点:`WebContainerViewController.setupExternalSubscriptions`(与 battery/network/appservice
|
||||
同一生命周期,避免双发);`teardownExternalSubscriptions` removeObserver
|
||||
- [x] **6.7** 子游戏 zip 下载 / 解压(H5 端通过 SwitchOverGameData 传 `gamedownloadurl`)
|
||||
- `Source/Resource/SubGameDownloader.swift`:actor 单例,URLSession + ZIPFoundation
|
||||
- 缓存策略:`{Caches}/{gameDir}/{gameStart}/index.html` 已存在 → `.alreadyExists` 直接复用;
|
||||
@@ -924,10 +933,10 @@ H5 调 `OpenurlTitleData` 打开弹层 WebView,弹层内 H5 用 `window.settin
|
||||
### Phase 6 子游戏
|
||||
- [x] 6.1 AppCoordinator 栈深节流(2s + viewControllers.count < 2)
|
||||
- [x] 6.2 SubGameViewController 框架(commit B 接入 SubGameDownloader 后真实下载/缓存命中)
|
||||
- [ ] 6.3 SubGameHandlers(backgameData 留待 commit C)
|
||||
- [x] 6.3 子游戏 handler 拆散注册(含 BackGameDataHandler;视频房间留 Phase 8)
|
||||
- [x] 6.4 SwitchOverGameData → AppCoordinator.showSubGame
|
||||
- [ ] 6.5 backgameData
|
||||
- [ ] 6.6 getWebdata 通知链
|
||||
- [x] 6.5 backgameData(停 audio + popSubGame + JSON 序列化兼容)
|
||||
- [x] 6.6 getWebdata 通知链(.subGameDidReturn 观察者挂在 ExternalSubscriptions 生命周期)
|
||||
- [x] 6.7 SubGameDownloader(actor,URLSession + ZIPFoundation + staging + 原子 rename)
|
||||
|
||||
### Phase 7 弹层
|
||||
|
||||
Reference in New Issue
Block a user