From 46f8a1e6138fa846072649b47a29b96d5cecf098 Mon Sep 17 00:00:00 2001 From: kdletters <61648117+kdletters@users.noreply.github.com> Date: Wed, 27 May 2026 04:25:09 +0800 Subject: [PATCH] fix: allow guest recommend swipe --- .hermes/shared-memory/pitfalls.md | 8 +++++ .../RpgEntryHomeView.recharge.test.tsx | 35 +++++++++++++++++++ src/components/rpg-entry/RpgEntryHomeView.tsx | 2 -- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.hermes/shared-memory/pitfalls.md b/.hermes/shared-memory/pitfalls.md index acec81b3..bf8af0d3 100644 --- a/.hermes/shared-memory/pitfalls.md +++ b/.hermes/shared-memory/pitfalls.md @@ -1607,3 +1607,11 @@ - 处理:后续如果需要重新暴露存档入口,优先评估是否应回到“玩过”或别的独立弹窗流程,不要默认把存档再塞回常用功能宫格或设置列表。 - 验证:`npm test -- src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx -t "mobile profile page matches the reference layout sections|profile scan action opens camera scanner instead of recharge panel"`。 - 关联:`src/components/rpg-entry/RpgEntryHomeView.tsx`、`docs/【项目基线】当前产品与工程约束-2026-05-15.md`、`docs/【玩法创作】平台入口与玩法链路-2026-05-15.md`。 + +## 访客推荐页上下滑不要绑定登录态 + +- 现象:访客模式进入移动端推荐页后,推荐内容可展示和点击底部“下一个”,但在作品信息区域上下滑不会切换推荐作品,表现为推荐页不能上下滑动。 +- 原因:推荐页滑动切换逻辑 `beginRecommendDrag(...)` 误把 `isAuthenticated` 作为启用条件;访客态虽然允许浏览和通过底部按钮切换,却无法触发同一套拖拽切换。 +- 处理:推荐页拖拽只校验当前是否有作品、多作品可切换以及是否正在提交动画,不再要求登录;登录态相关操作仍由点赞、改造等按钮自身权限控制。 +- 验证:`npx vitest run src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx` 覆盖访客态纵向滑动不弹登录且触发下一条推荐。 +- 关联:`src/components/rpg-entry/RpgEntryHomeView.tsx`、`src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx`。 diff --git a/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx b/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx index e6646295..36eb42f0 100644 --- a/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx +++ b/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx @@ -3246,6 +3246,41 @@ test('logged out active recommend bottom tab selects next work without login', a expect(openLoginModal).not.toHaveBeenCalled(); }); +test('logged out recommend card supports vertical swipe without login', () => { + vi.useFakeTimers(); + const onSelectNextRecommendEntry = vi.fn(); + const openLoginModal = vi.fn(); + + renderLoggedOutHomeView(openLoginModal, { + latestEntries: [ + puzzlePublicEntry, + { + ...puzzlePublicEntry, + workId: 'puzzle-work-guest-next', + profileId: 'puzzle-profile-guest-next', + ownerUserId: 'user-guest-next', + publicWorkCode: 'PZ-GUEST-NEXT', + worldName: '访客下一张', + }, + ], + activeRecommendEntryKey: 'puzzle:user-2:puzzle-profile-public-1', + onSelectNextRecommendEntry, + recommendRuntimeContent:
, + }); + + const meta = screen.getByLabelText('奇幻拼图 作品信息') as HTMLElement; + act(() => { + dispatchPointerEvent(meta, 'pointerdown', { pointerId: 1, clientY: 320 }); + dispatchPointerEvent(meta, 'pointermove', { pointerId: 1, clientY: 220 }); + dispatchPointerEvent(meta, 'pointerup', { pointerId: 1, clientY: 220 }); + vi.advanceTimersByTime(180); + }); + + expect(onSelectNextRecommendEntry).toHaveBeenCalledTimes(1); + expect(openLoginModal).not.toHaveBeenCalled(); + vi.useRealTimers(); +}); + test('mobile recommend meta loads real author avatar from public user summary', async () => { mockGetPublicAuthUserById.mockResolvedValueOnce({ id: 'user-2', diff --git a/src/components/rpg-entry/RpgEntryHomeView.tsx b/src/components/rpg-entry/RpgEntryHomeView.tsx index 8bcbe2b1..07ada522 100644 --- a/src/components/rpg-entry/RpgEntryHomeView.tsx +++ b/src/components/rpg-entry/RpgEntryHomeView.tsx @@ -5282,7 +5282,6 @@ export function RpgEntryHomeView({ (event: PointerEvent