refactor: 收口公开码搜索映射

This commit is contained in:
2026-06-04 06:04:55 +08:00
parent 217cc881e6
commit e570d50e9f
9 changed files with 749 additions and 123 deletions

View File

@@ -12,26 +12,29 @@
- `resolvePlatformPublicCodeSearchPlan(keyword)`:输入用户搜索词,输出 `{ normalizedKeyword, steps }`;空输入返回 `null`
- `PlatformPublicCodeSearchStep`:枚举壳层可执行的查找步骤,包括 `user-id``public-user-code``rpg-work`、各玩法公开作品步骤与 `bark-battle-work`
- `mapRpgPublicCodeSearchDetailToGalleryCard(entry)`:把 RPG by-code 详情响应映射为公开作品卡,收口 `playCount` / `remixCount` / `likeCount``0` 兜底。
- `resolve*PublicCodeSearchMatch(entries, keyword)`:统一各玩法公开作品列表的公开码匹配、公开可见性过滤和详情卡 DTO 映射;拼图、大鱼吃小鱼、跳一跳、敲木鱼、宝贝识物、抓大鹅、方洞挑战、视觉小说和汪汪声浪都走此接口。
`PlatformEntryFlowShellImpl.tsx` 仍作为 **Adapter**:它保留 `getPublicAuthUserByCode`、各玩法 gallery 刷新 / 详情打开、Bark Battle runtime 特例和 missing work 归航副作用,只按 `steps` 顺序执行,前一步失败才尝试下一步。
`PlatformEntryFlowShellImpl.tsx` 仍作为 **Adapter**:它保留 `getPublicAuthUserByCode`、各玩法 gallery 刷新 / 详情打开、Bark Battle runtime 特例和 missing work 归航副作用,只按 `steps` 顺序执行,前一步失败才尝试下一步;壳层不再重复维护 per-play `isSame*PublicWorkCode` 匹配和 DTO 映射
## Interface 约束
- 空白搜索词返回 `null`,壳层不得进入搜索 loading。
- `user_` / `user-` 开头的内部用户 ID 只执行 `user-id`,不回退作品号。
- `PZ``BF``JH``WF``BO``M3``SH``VN``BB` 前缀只进入对应玩法公开作品查找;`M3D-*` 继续归入 `M3` / 抓大鹅。
- `PZ``BF``JH``WF``BO``M3``SH``VN``BB` 前缀只进入对应玩法公开作品查找;`M3D-*` 继续归入并匹配 `M3` / 抓大鹅。
- `CW``1-8` 位纯数字先查 RPG 公开作品,再回退陶泥号。
- 普通关键词与 `SY` 陶泥号保持既有顺序:先查陶泥号,再查 RPG 公开作品,再查汪汪声浪作品,最后再以陶泥号兜底。
## Depth / Leverage / Locality
- **Depth**:壳层只消费短小的 `steps` Interface搜索前缀、优先级回退顺序藏入 Module Implementation。
- **Leverage**:新增公开作品前缀时,先扩展 Module 的 step union、前缀表和单测再在壳层 Adapter 绑定对应执行函数
- **Locality**:搜索计划规则集中在一个纯 ModuleUI、网络、详情打开与 runtime 启动副作用继续留在壳层,避免把副作用 setter 变成浅 Interface。
- **Depth**:壳层只消费短小的 `steps` 与 match result Interface搜索前缀、优先级回退顺序、per-play 匹配和 DTO 映射藏入 Module Implementation。
- **Leverage**:新增公开作品前缀时,先扩展 Module 的 step union、前缀表、matcher 和单测,再在壳层 Adapter 绑定对应网络读取与打开动作
- **Locality**:搜索计划与作品命中规则集中在一个纯 ModuleUI、网络、详情打开与 runtime 启动副作用继续留在壳层,避免把副作用 setter 变成浅 Interface。
## 验收
- `npm run test -- src/components/platform-entry/platformPublicCodeSearchModel.test.ts`
- `npm run test -- src/services/publicWorkCode.test.ts`
- `npx eslint src/components/platform-entry/platformPublicCodeSearchModel.ts src/components/platform-entry/platformPublicCodeSearchModel.test.ts src/components/platform-entry/PlatformEntryFlowShellImpl.tsx --quiet`
- `npm run typecheck`
- `npm run check:encoding`