拆分领取页 ClaimPage 为多模块

将 snapshot、轮询、共享 UI、UID/lewan/feifei 步骤组件物理拆分,主文件只保留页面编排与状态。
This commit is contained in:
yml2213
2026-07-10 13:55:43 +08:00
parent 8de56b0354
commit c70c3ff6a5
8 changed files with 968 additions and 940 deletions
@@ -0,0 +1,68 @@
import { isClaimInactiveTaskStatus } from '@/domain/task-status'
import type { ClaimSnapshot } from './claim-snapshot'
export const BINDING_PREPARE_POLL_MS = 5_000
export const ROLE_FAST_POLL_MS = 10_000
export const ROLE_SLOW_POLL_MS = 30_000
export const ROLE_IDLE_POLL_MS = 60_000
export const ROLE_FAST_WINDOW_MS = 3 * 60_000
export const ROLE_IDLE_WINDOW_MS = 10 * 60_000
export const FEIFEI_POLL_MS = 15_000
export function resolveRolePollDelayMs(
nextSnapshot: ClaimSnapshot,
baseline: { roleKey: string; at: number },
now = Date.now(),
) {
const nextRoleKey = [nextSnapshot.roleName, nextSnapshot.roleId].join('::')
let baselineAt = baseline.at
let baselineKey = baseline.roleKey
if (nextRoleKey !== baselineKey) {
baselineKey = nextRoleKey
baselineAt = now
}
if (!baselineAt) {
baselineAt = now
}
const elapsedMs = now - baselineAt
let delay = ROLE_IDLE_POLL_MS
if (elapsedMs < ROLE_FAST_WINDOW_MS) {
delay = ROLE_FAST_POLL_MS
} else if (elapsedMs < ROLE_IDLE_WINDOW_MS) {
delay = ROLE_SLOW_POLL_MS
}
return {
delay,
baseline: { roleKey: baselineKey, at: baselineAt },
}
}
export function resolveNextPollDelayMs(
nextSnapshot: ClaimSnapshot,
rolePollDelayMs: number,
): number {
if (nextSnapshot.hasRedeemResult || isClaimInactiveTaskStatus(nextSnapshot.task?.status)) {
return 0
}
if (!nextSnapshot.hasExpectedUid) {
return 0
}
if (nextSnapshot.isFeifeiFlow) {
return FEIFEI_POLL_MS
}
if (nextSnapshot.currentStep === 2) {
if (!nextSnapshot.isBindingPrepared) {
return BINDING_PREPARE_POLL_MS
}
return rolePollDelayMs
}
return 0
}