From bdf99468e7366b71ce7699ce90df353fbd85c735 Mon Sep 17 00:00:00 2001 From: kdletters <61648117+kdletters@users.noreply.github.com> Date: Sat, 13 Jun 2026 20:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A8=E8=8D=90=E9=A1=B5?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E5=88=87=E6=8D=A2=E5=9B=9E=E5=BC=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为推荐页滑动提交后的 rail 复位增加无过渡 resetting 状态 补充推荐滑动状态模型测试覆盖 resetting 类名 补齐推荐页交互测试中的小程序运行态 mock --- .../RpgEntryFlowShell.agent.interaction.test.tsx | 3 +++ src/components/rpg-entry/RpgEntryHomeView.tsx | 10 ++++++++++ .../rpg-entry/rpgEntryRecommendSwipeDeckModel.test.ts | 7 +++++++ .../rpg-entry/rpgEntryRecommendSwipeDeckModel.ts | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx b/src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx index e91bc908..226fc288 100644 --- a/src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx +++ b/src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx @@ -200,6 +200,7 @@ const authServiceMocks = vi.hoisted(() => ({ token: 'runtime-guest-token', expiresAt: '2099-01-01T00:00:00.000Z', })), + isWechatMiniProgramWebViewRuntime: vi.fn(() => false), getPublicAuthUserByCode: vi.fn( async (publicUserCode: string): Promise => ({ id: `public-user-${publicUserCode}`, @@ -222,6 +223,8 @@ const authServiceMocks = vi.hoisted(() => ({ vi.mock('../../services/authService', () => ({ ensureRuntimeGuestToken: authServiceMocks.ensureRuntimeGuestToken, + isWechatMiniProgramWebViewRuntime: + authServiceMocks.isWechatMiniProgramWebViewRuntime, getPublicAuthUserByCode: authServiceMocks.getPublicAuthUserByCode, getPublicAuthUserById: authServiceMocks.getPublicAuthUserById, })); diff --git a/src/components/rpg-entry/RpgEntryHomeView.tsx b/src/components/rpg-entry/RpgEntryHomeView.tsx index f649b0d4..8d5f319c 100644 --- a/src/components/rpg-entry/RpgEntryHomeView.tsx +++ b/src/components/rpg-entry/RpgEntryHomeView.tsx @@ -3421,6 +3421,8 @@ export function RpgEntryHomeView({ const [recommendDragOffsetY, setRecommendDragOffsetY] = useState(0); const [recommendDragCommitDirection, setRecommendDragCommitDirection] = useState(null); + const [isRecommendDragResetting, setIsRecommendDragResetting] = + useState(false); const activeRecommendEntryKeyForSelection = recommendFeedWindow.activeEntryKey; const recommendCardStageRef = useRef(null); @@ -3435,6 +3437,7 @@ export function RpgEntryHomeView({ return; } + setIsRecommendDragResetting(false); setRecommendDragCommitDirection(direction); const panelHeight = recommendCardStageRef.current?.getBoundingClientRect().height ?? 0; @@ -3451,8 +3454,12 @@ export function RpgEntryHomeView({ } else { onSelectPreviousRecommendEntry?.(activeRecommendEntryKeyForSelection); } + setIsRecommendDragResetting(true); setRecommendDragOffsetY(0); setRecommendDragCommitDirection(null); + window.requestAnimationFrame(() => { + setIsRecommendDragResetting(false); + }); }, RECOMMEND_ENTRY_COMMIT_ANIMATION_MS); }, [ @@ -3514,6 +3521,7 @@ export function RpgEntryHomeView({ const deltaY = event.clientY - drag.startY; const commitDirection = resolveRecommendDragCommitDirection(deltaY); if (!commitDirection) { + setIsRecommendDragResetting(false); setRecommendDragOffsetY(0); return; } @@ -3529,6 +3537,7 @@ export function RpgEntryHomeView({ event.currentTarget.releasePointerCapture?.(drag.pointerId); } recommendDragStartRef.current = null; + setIsRecommendDragResetting(false); setRecommendDragOffsetY(0); }, [], @@ -3539,6 +3548,7 @@ export function RpgEntryHomeView({ const recommendRailClassName = buildRecommendSwipeRailClassName({ offsetY: recommendDragOffsetY, commitDirection: recommendDragCommitDirection, + isResetting: isRecommendDragResetting, }); const selectNextRecommendEntry = useCallback(() => { if ( diff --git a/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.test.ts b/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.test.ts index b412a40c..a3da6a21 100644 --- a/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.test.ts +++ b/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.test.ts @@ -38,6 +38,13 @@ describe('rpgEntryRecommendSwipeDeckModel', () => { expect( buildRecommendSwipeRailClassName({ offsetY: -320, commitDirection: 1 }), ).toBe('platform-recommend-swipe-rail--committing'); + expect( + buildRecommendSwipeRailClassName({ + offsetY: 0, + commitDirection: null, + isResetting: true, + }), + ).toBe('platform-recommend-swipe-rail--resetting'); expect( shouldAnimateRecommendSwipe({ diff --git a/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.ts b/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.ts index f0db81cc..a51a2c4f 100644 --- a/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.ts +++ b/src/components/rpg-entry/rpgEntryRecommendSwipeDeckModel.ts @@ -9,6 +9,7 @@ export type RecommendSwipeDirection = 1 | -1; export type RecommendSwipeRailState = { offsetY: number; commitDirection: RecommendSwipeDirection | null; + isResetting?: boolean; }; /** 收口推荐卡纵向滑动的纯判定,页面只保留 pointer 与动画副作用。 */ @@ -47,6 +48,10 @@ export function resolveRecommendCommitOffset( export function buildRecommendSwipeRailClassName( state: RecommendSwipeRailState, ) { + if (state.isResetting) { + return 'platform-recommend-swipe-rail--resetting'; + } + if (state.commitDirection) { return 'platform-recommend-swipe-rail--committing'; }