根因:经局域网 IP 明文 http(如 http://100.64.0.7:4173)跨内网机访问时,浏览器判为 「非安全上下文」,window.crypto.subtle 为 undefined。inject.ts 的 sha256Hex 旧实现此时 直接抛错 → fetchAndVerifyManifest 完整性校验失败 → GamePlayer 退 demo 兜底,而 W-CLEAN 后 demo 是「模板体系重构中」并发 game_error → 页面误报「游戏加载失败/网络波动」(真因是上下文 不安全,非网络)。门禁此前经 localhost(安全上下文)走查,subtle 可用,故漏过此类上下文依赖缺陷。 修复:sha256Hex 改双通道——优先 Web Crypto SubtleCrypto(安全上下文,原生最快);缺失时回退 纯 JS SHA-256(FIPS 180-4,零依赖,确定性)。两通道对同一份 UTF-8 字节摘要,结果逐字节一致, 使 manifest 完整性校验在「明文 IP http」与「安全上下文」下行为一致,整款引擎游戏正常装载。 仅改 game-studio/src/host/inject.ts(+89/-12),不动契约/不放宽 CSP/不削弱完整性校验。 验证: ① 纯 JS SHA-256 对已知向量 + 跨块边界 + 真 manifest(214KB→456c38cb,与后端 checksum 及 node crypto 三方一致)13/13 通过; ② npm run build -- --mode staging(vue-tsc -b 真类型门 + vite build)EXIT=0; ③ CDP 经 http://100.64.0.7:4173(实测 isSecureContext=false、crypto.subtle 缺失)深链 /play/9306/93112:真 LittleJS 引擎装载、井字棋棋盘渲染、loading 收起、无 [GamePlayer] 兜底 warn、无错误态——修复前同路径报「游戏加载失败」。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Vue 3 + TypeScript + Vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.
Learn more about the recommended Project Setup and IDE Support in the Vue Docs TypeScript Guide.