 joywayerandClaude Opus 4.7
|
04e702a99b
|
Phase 1.F: WebView 加载从 file:// 迁到 ylgame://h5 自定义 scheme
为未来 Cocos 子游戏 H5 build 适配铺路(file:// 下 Cocos XHR/fetch 受
null-origin 限制几乎必踩坑),同时保留大厅 + 子游戏跨页 localStorage
共享语义(用单虚拟 host `h5` 让所有 H5 same-origin)。
变更:
- 新增 AppSchemeHandler(WKURLSchemeHandler 单例 + Range/MIME/异步 IO/
取消语义;闭包只携 Sendable ObjectIdentifier,不捕获 task)
- SandboxPaths 加 lobbyIndexAppURL / subGameIndexAppURL builders
- BridgedWebView 注册 scheme handler(WKWebView init 前)
- WebContainerViewController / SubGameViewController 的 loadFileURL
→ webView.load(URLRequest),OverlayViewController 不变
文档:
- Plan 新增 Phase 1.F (1.18-1.21) + ADR-010 决策记录 + 进度勾选
- Design 新增 §7.6 包含 URL 结构 / 实现要点 / 等价性表 / Cocos 预检脚本
- Contract §0.2 / §4.1 / §10 验收清单同步切换说明(H5 可观察差异:
location.protocol "file:" → "ylgame:",项目方已 grep 确认现网 H5
不依赖此字面)
存量影响:file:// → ylgame:// origin 切换时老用户 localStorage 一次性
清零,已与项目方确认业务可接受、不做迁移补偿。
BuildProject 通过。Plan 进度已勾选 1.18/1.19/1.20。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-06-29 08:58:00 +08:00 |
|
joywayer
|
463f0fc6fe
|
Phase 1.5:ResourceUnzipper 解压 gamehall.zip 到 Caches 全链路打通
启动期完成「ChannelConfig.plist 读 → SandboxPaths 算路径 →
gamehall.zip 解压」三步,lobbyIndex 真实存在于沙盒 Caches,
为 Phase 1.10 WebContainer file:// 加载就绪。
- 新增 ylgamehall/Source/Resource/ResourceUnzipper.swift
- public actor,全局单例 ResourceUnzipper.shared
- ensureReady() async throws:检查 lobbyVersionXML 不存在则调
FileManager.unzipItem (ZIPFoundation 扩展) 解压 Bundle 内
gamehall.zip 到 SandboxPaths.lobbyRoot
- UnzipError 类型化错误(bundleZipNotFound / unzipFailed)
- 幂等:已就绪直接 return,并发调用安全(actor 串行)
- 新增 ylgamehall/Resources/gamehall.zip:从 docs/res 拷一份入
Bundle(11.5 MB,2023-12 旧版;上线前由 H5 团队替换最新版,
ADR-002 已记录)
- Swift 6 严格并发适配:
- SandboxPaths:所有 static 成员标 nonisolated(无状态命名空间,
从 actor / 非 MainActor 上下文都能直接读 caches/documents/bundle
及 lobby 路径计算)
- BundleConfig:class 整体 nonisolated(Sendable + all-let 属性,
跨 actor 边界安全),允许 ResourceUnzipper actor 读 channel 配置
- RootViewController 补 ResourceUnzipper 烟雾测试 Task:
await ensureReady() 后打印耗时 + lobbyIndex 是否真实存在
- 真机验证(iOS Simulator):首次 1.266s 解压成功,二次启动 0s 跳过
|
2026-06-22 00:01:08 +08:00 |
|
joywayer
|
730574a2e2
|
Phase 1.3:SandboxPaths 统一沙盒 / Bundle / H5 路径入口
集中管理 NSSearchPathFor... 调用,避免散落,方便后续 ResourceUnzipper
(Phase 1.5)与 WebView 加载(Phase 1.10)复用。
- 新增 ylgamehall/Source/Resource/SandboxPaths.swift
- 基础:caches / documents / bundle
- 大厅 H5:lobbyRoot / lobbyIndex / lobbyVersionXML(基于 BundleConfig
当前渠道值动态拼接)
- 子游戏 H5:subGameRoot(_:) / subGameIndex(_:_:)(Phase 6 调用,
入参传 SwitchOverGameData 解出的 dir/start)
- 全部 enum + static,无状态,Swift 6 严格并发零负担
- RootViewController.viewDidLoad 补 SandboxPaths 烟雾打印 6 项路径,
便于首次启动 console 校验:
- lobbyIndex 应为 {Caches}/FtJf073.../gamehall/index.html
- lobbyVersionXML 应为 {Caches}/FtJf073.../gamehall/version.xml
- BuildProject 通过,synchronized group 自动收编新文件
|
2026-06-21 23:52:23 +08:00 |
|