fix(semi-auto): 刷新绑定二维码 5 秒内复用当前码
This commit is contained in:
@@ -46,6 +46,8 @@ import { runWeiboYidunChallenge } from '@/utils/weibo-yidun'
|
||||
import HuyaChallengeModal from './HuyaChallengeModal'
|
||||
|
||||
const POLL_INTERVAL_MS = 2000
|
||||
// 刷新绑定二维码的冷却时间:避免连续点击频繁请求虎牙。
|
||||
const BINDING_REFRESH_COOLDOWN_MS = 3_000
|
||||
|
||||
const SERVER_ZONE_OPTIONS = ['苹果Q区', '苹果V区', '安卓Q区', '安卓V区']
|
||||
|
||||
@@ -88,6 +90,7 @@ export default function CustomerFulfillmentPage({
|
||||
const [profileSaving, setProfileSaving] = useState(false)
|
||||
const [profileEditing, setProfileEditing] = useState(false)
|
||||
const startingBindingRef = useRef(false)
|
||||
const lastBindingRefreshAtRef = useRef(0)
|
||||
const resettingBindingRef = useRef(false)
|
||||
const hydratingBindingRef = useRef(false)
|
||||
const autoOpenedRoleRef = useRef('')
|
||||
@@ -176,6 +179,7 @@ export default function CustomerFulfillmentPage({
|
||||
setBindingInfo(null)
|
||||
setBindingConfirmOpen(false)
|
||||
startingBindingRef.current = false
|
||||
lastBindingRefreshAtRef.current = 0
|
||||
hydratingBindingRef.current = false
|
||||
autoOpenedRoleRef.current = ''
|
||||
weiboBindingSyncRef.current = false
|
||||
@@ -608,6 +612,12 @@ export default function CustomerFulfillmentPage({
|
||||
|
||||
async function handleRefreshBinding(forceRebind: boolean) {
|
||||
if (!selectedTask) return
|
||||
const now = Date.now()
|
||||
if (now - lastBindingRefreshAtRef.current < BINDING_REFRESH_COOLDOWN_MS) {
|
||||
message.warning('操作频繁,请稍后再试')
|
||||
return
|
||||
}
|
||||
lastBindingRefreshAtRef.current = now
|
||||
setBindingLoading(true)
|
||||
try {
|
||||
const response = await startCustomerBinding(orderNo, selectedTask.id, { forceRebind })
|
||||
|
||||
Reference in New Issue
Block a user