fix(douyu): 确认绑定回查按已生效绑定判定并支持同步延迟等待 & 失败提示优化为待绑定账号换绑限制文案 & 前端居中弹窗提示
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
} from 'antd';
|
||||
import type { TableProps } from 'antd';
|
||||
import {
|
||||
CheckCircleOutlined, CopyOutlined, CreditCardOutlined, FieldTimeOutlined, GiftOutlined,
|
||||
CheckCircleOutlined, CopyOutlined, CreditCardOutlined, ExclamationCircleOutlined, FieldTimeOutlined, GiftOutlined,
|
||||
ImportOutlined, QrcodeOutlined, ReloadOutlined,
|
||||
SearchOutlined, SettingOutlined, ShoppingOutlined, StopOutlined,
|
||||
} from '@ant-design/icons';
|
||||
@@ -116,6 +116,7 @@ const ESPORTS_TASK_TYPES = new Set([
|
||||
]);
|
||||
const DOUYU_GOLD_AMOUNT_STORAGE_KEY = 'douyu_task_gold_amount';
|
||||
const DOUYU_GIFT_COUNT_STORAGE_KEY = 'douyu_task_gift_count';
|
||||
const CONFIRM_FAIL_TIP_SECONDS = 6;
|
||||
|
||||
function resultText(result: Record<string, unknown> | null | undefined, key: string): string {
|
||||
const value = result?.[key];
|
||||
@@ -308,6 +309,9 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
||||
const autoOpenedEsportsBindTaskIds = useRef<Set<number>>(new Set());
|
||||
const autoOpenedPayTaskIds = useRef<Set<number>>(new Set());
|
||||
const autoCopiedExchangeTaskIds = useRef<Set<number>>(new Set());
|
||||
const autoNotifiedConfirmFailedTaskIds = useRef<Set<number>>(new Set());
|
||||
const [confirmFailTip, setConfirmFailTip] = useState<{ taskId: number; message: string } | null>(null);
|
||||
const [confirmFailCountdown, setConfirmFailCountdown] = useState(0);
|
||||
const [exchangePreview, setExchangePreview] = useState<{ task: DouyuTaskItem; url: string } | null>(null);
|
||||
const autoOpenQrReady = useRef(false);
|
||||
const autoOpenEsportsBindReady = useRef(false);
|
||||
@@ -608,6 +612,40 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
||||
);
|
||||
}, [visibleTasks]);
|
||||
|
||||
// 确认绑定失败自动弹提示(页面中央弹窗,自动消失,一次性去重)
|
||||
useEffect(() => {
|
||||
if (!autoOpenQrReady.current) return;
|
||||
const failedTasks = visibleTasks
|
||||
.filter((task) => (
|
||||
task.task_type === 'confirm_bind'
|
||||
&& ['failed', 'error'].includes(task.status)
|
||||
&& (task.message || '').includes('待绑定游戏账号')
|
||||
&& !autoNotifiedConfirmFailedTaskIds.current.has(task.id)
|
||||
))
|
||||
.sort((a, b) => b.id - a.id);
|
||||
if (failedTasks.length === 0) return;
|
||||
for (const task of failedTasks) autoNotifiedConfirmFailedTaskIds.current.add(task.id);
|
||||
const latest = failedTasks[0];
|
||||
setConfirmFailTip({ taskId: latest.id, message: latest.message });
|
||||
}, [visibleTasks]);
|
||||
|
||||
// 弹窗倒计时自动关闭
|
||||
useEffect(() => {
|
||||
if (!confirmFailTip) return;
|
||||
setConfirmFailCountdown(CONFIRM_FAIL_TIP_SECONDS);
|
||||
const timer = setInterval(() => {
|
||||
setConfirmFailCountdown((cur) => {
|
||||
if (cur <= 1) {
|
||||
clearInterval(timer);
|
||||
setConfirmFailTip(null);
|
||||
return 0;
|
||||
}
|
||||
return cur - 1;
|
||||
});
|
||||
}, 1000);
|
||||
return () => clearInterval(timer);
|
||||
}, [confirmFailTip]);
|
||||
|
||||
const copyExchangePreview = async () => {
|
||||
if (!exchangePreview) return;
|
||||
try {
|
||||
@@ -1891,6 +1929,27 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
||||
</Space>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
{/* 确认绑定失败提示 Modal(居中,自动消失) */}
|
||||
<Modal
|
||||
title={<Space><ExclamationCircleOutlined style={{ color: '#faad14' }} /><span>绑定失败提示</span></Space>}
|
||||
open={Boolean(confirmFailTip)}
|
||||
onCancel={() => setConfirmFailTip(null)}
|
||||
footer={null}
|
||||
centered
|
||||
closable={false}
|
||||
width={420}
|
||||
>
|
||||
<div style={{ textAlign: 'center', padding: '16px 8px 8px' }}>
|
||||
<ExclamationCircleOutlined style={{ fontSize: 42, color: '#faad14' }} />
|
||||
<div style={{ fontSize: 14, marginTop: 14, lineHeight: 1.7 }}>
|
||||
{confirmFailTip?.message || ''}
|
||||
</div>
|
||||
<Text type="secondary" style={{ fontSize: 12, marginTop: 12, display: 'inline-block' }}>
|
||||
{confirmFailCountdown} 秒后自动关闭
|
||||
</Text>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user