补齐游戏分发网页发布链路并修掉发布灰度按匿名判定
Project CI / AI game creator shell Rust crates (push) Successful in 1m34s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m54s
Project CI / Backend tests (push) Successful in 4m9s
Project CI / Frontend tests (push) Successful in 2m6s
Project CI / Native shell tests (push) Successful in 6m22s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 8m32s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 9m31s
Project CI / AI game creator shell web tests (push) Successful in 1m37s
Project CI / Repository checks (push) Successful in 2m17s

- 新增 scripts/check-game-distribution-web-publish-e2e.mjs:网页登录、选封面、选发行包 ZIP、填资料提交,待审不可见、审核后公开、更新沿用同一 gameId 且旧版在线,共 12 项 PASS
- frontendRuntimeConfigService 去掉 skipAuth:发布灰度按作者判定,匿名请求恒为 false,之前只要显式配置过灰度网页端就永远没有发布入口;单测同步更新
- 游戏分发里程碑阶段 C 第 4 条改为已勾选,第 5 条缺口收窄到上传中断/双击/登录失效/窗口关闭与换账号
- pitfalls 记录「按用户灰度配置不能走 skipAuth」的经验
This commit is contained in:
kdletters
2026-09-28 20:21:34 +08:00
parent f0ae3ce52c
commit bbbd91db88
6 changed files with 367 additions and 5 deletions
@@ -6068,4 +6068,9 @@ Cocos Creator 根目录由 `package.json.creator.version` 与普通 `assets/`
## 2026-09-28 开发态 StrictMode 双跑 effect 击穿「一次性初始化」守卫;Vite dev 缺发行入口代理
- **现象 1(真实缺陷)**:从游戏详情返回目录后,之前输入的关键词被清空(分类/设备还在)。`GameGalleryPage` 用 `didSyncPropKeywordRef` 守卫「顶栏搜索词覆盖目录筛选」,React 开发态 StrictMode 会把挂载 effect 跑两遍:第一遍设标记并返回,第二遍就拿着空 `searchKeyword` 把刚从 `sessionStorage` 恢复的关键词清掉。**处理**:改成按 prop 值比对(`lastPropKeywordRef`),只有 prop 真的变化才覆盖本地筛选;`GameDistributionPages.test.tsx` 与网页 E2E 都回归通过。教训:任何「只在首次挂载跳过」的 ref 守卫都要按 StrictMode 双跑来审一遍。
- **现象 2(dev 栈对齐)**:平台同源发行入口 `/games/<gameId>/` 在生产由 nginx 映射到发行网关并清空 Cookie,本地 Vite 代理没有这条规则,iframe 会落到 SPA 外壳(看起来“加载成功”,其实是壳)。**处理**:`vite.config.ts` 增加 `^/games/game_[0-9a-f]{32}(?:/.*)?$` 代理,rewrite 到 `/api/game-distribution/releases/…` 并去掉 Cookie 头,本地网页栈与生产同口径;`check:game-distribution-web-e2e` 里用「iframe 文本包含包内标记」断言真正载入的是发行包。
- **现象 2(dev 栈对齐)**:平台同源发行入口 `/games/<gameId>/` 在生产由 nginx 映射到发行网关并清空 Cookie,本地 Vite 代理没有这条规则,iframe 会落到 SPA 外壳(看起来“加载成功”,其实是壳)。**处理**:`vite.config.ts` 增加 `^/games/game_[0-9a-f]{32}(?:/.*)?$` 代理,rewrite 到 `/api/game-distribution/releases/…` 并去掉 Cookie 头,本地网页栈与生产同口径;`check:game-distribution-web-e2e` 里用「iframe 文本包含包内标记」断言真正载入的是发行包。
## 2026-09-28 前端运行时配置接口用 skipAuth 调用,导致显式配置发布灰度后网页端永远没有发布入口
- **现象**:运营把 `game-distribution:publish` 显式配置成 `enabled=true, rolloutPercent=100` 后,登录作者在网页 `/games/publish` 仍看到「发布功能正在灰度中 / 当前账号还没有发布入口」,但用同一账号的 access token 直接请求 `/api/runtime/frontend-config` 得到 `gameDistributionPublishEnabled=true`。
- **根因**:`src/services/frontendRuntimeConfigService.ts` 的 `loadFrontendRuntimeConfig()` 传了 `skipAuth: true`,请求不带登录态;而发布灰度是**按作者**判定的(匿名恒为 false),所以壳层拿到的永远是匿名结果。
- **处理**:去掉 `skipAuth`(保留 `skipRefresh` 等选项),登录后壳层按 `gamePublishGateUserId` 重读配置即可拿到发布入口;`frontendRuntimeConfigService.test.ts` 与 `check:game-distribution-web-publish-e2e` 都覆盖回归。教训:任何「按用户/作者灰度」的配置接口都不能走 `skipAuth`,匿名结果与登录结果语义不同。