refactor: 收口玩过作品打开意图
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# 【前端架构】Platform Played Work Open Model 收口计划
|
||||
|
||||
## 背景
|
||||
|
||||
`PlatformEntryFlowShellImpl.tsx` 的个人“玩过作品”点击回调曾在壳层内直接判断 `worldType`、`worldKey` 前缀、玩法别名、目标 ID 兜底、RPG 公开详情 payload 和大鱼吃小鱼 gallery miss fallback。壳层因此同时承载纯打开意图与异步副作用,后续新增玩法或修正玩过作品身份时缺少稳定测试面。
|
||||
|
||||
个人“玩过作品”的点击规则属于打开意图。壳层应只关闭面板、读取 gallery、打开详情和写错误;玩法别名、目标 ID、fallback payload 应收口到纯 **Module**。
|
||||
|
||||
## 决策
|
||||
|
||||
新增 `src/components/platform-entry/platformPlayedWorkOpenModel.ts` 作为 Platform Played Work Open **Module**。其公开 **Interface** 为:
|
||||
|
||||
- `resolvePlatformPlayedWorkOpenIntent(work)`:输入 `ProfilePlayedWorkSummary`,输出 `noop`、各玩法公开详情打开意图、`open-big-fish` 或 `open-rpg`。
|
||||
- `PlatformPlayedWorkOpenIntent`:描述壳层可执行的打开动作;大鱼吃小鱼意图包含 `sessionId` 和 gallery miss 时使用的 `fallbackWork`,RPG 意图包含 `CustomWorldGalleryCard` 详情 payload。
|
||||
|
||||
`PlatformEntryFlowShellImpl.tsx` 仍作为 **Adapter**:它保留 `setIsProfilePlayStatsOpen(false)`、各玩法 `open*PublicWorkDetail`、`refreshBigFishGallery()`、大鱼 gallery 命中优先逻辑、`mapBigFishWorkToPublicWorkDetail(...)` 与错误 setter。
|
||||
|
||||
## Interface 约束
|
||||
|
||||
- `worldType` 只做小写归一,不 trim;`worldKey` 前缀匹配保持大小写敏感,延续旧行为。
|
||||
- `profileId` 使用 nullish 优先级:只在 `profileId` 为 `null` / `undefined` 时从 `worldKey` 前缀兜底;空字符串仍视为缺目标并返回 `noop`。
|
||||
- `puzzle` 打开时固定携带 `{ tab: 'profile' }`。
|
||||
- `match3d` / `match_3d`、`square-hole` / `square_hole`、`jump-hop` / `jump_hop`、`wooden-fish` / `wooden_fish`、`big-fish` / `big_fish` 均保持既有别名。
|
||||
- `big-fish` 缺 gallery 命中时使用 Module 生成的 `fallbackWork`,默认 `ownerUserId` 为空串、`authorDisplayName` 为 `worldSubtitle || '玩家'`、关卡和素材 ready 计数为 `0` / `false`。
|
||||
- 未识别的 `worldType` 仍按 RPG 公开详情打开;缺 `ownerUserId` 或缺 profile 目标时返回 `noop`。
|
||||
|
||||
## Depth / Leverage / Locality
|
||||
|
||||
- **Depth**:调用方只消费一个打开 intent;玩法别名、目标 ID 兜底和 fallback payload 藏入 Module Implementation。
|
||||
- **Leverage**:新增“玩过作品”玩法时,先在 intent union、resolver 与单测中定义,再让壳层 Adapter 绑定对应打开副作用。
|
||||
- **Locality**:RPG fallback payload 与大鱼 fallback work 不再散落在大型壳层里,维护者可在纯测试中锁定字段契约。
|
||||
|
||||
## 验收
|
||||
|
||||
- `npm run test -- src/components/platform-entry/platformPlayedWorkOpenModel.test.ts`
|
||||
- `npx eslint src/components/platform-entry/platformPlayedWorkOpenModel.ts src/components/platform-entry/platformPlayedWorkOpenModel.test.ts src/components/platform-entry/PlatformEntryFlowShellImpl.tsx --quiet`
|
||||
- `npm run test -- src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx -t "authenticated users can open save archives from the profile played panel"`
|
||||
- `npm run typecheck`
|
||||
- `npm run check:encoding`
|
||||
Reference in New Issue
Block a user