优化自动钓鱼
This commit is contained in:
@@ -254,10 +254,46 @@
|
|||||||
errDiv.innerHTML =
|
errDiv.innerHTML =
|
||||||
`<span style="color:red;">【钓鱼】${data.message || '操作失败'}</span><span class="msg-time">(${timeStr})</span>`;
|
`<span style="color:red;">【钓鱼】${data.message || '操作失败'}</span><span class="msg-time">(${timeStr})</span>`;
|
||||||
container2.appendChild(errDiv);
|
container2.appendChild(errDiv);
|
||||||
_autoFishing = false; // 出错时停止循环
|
|
||||||
|
// 核心修复:如果是自动钓鱼中遇到超时或接口报错,不要中断,而是休眠5秒后重试抛竿
|
||||||
|
if (_autoFishing) {
|
||||||
|
const btn = document.getElementById('fishing-btn');
|
||||||
|
if (btn) {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.textContent = '⏳ 重试中...';
|
||||||
|
}
|
||||||
|
_autoFishCdTimer = setTimeout(() => {
|
||||||
|
_autoFishCdTimer = null;
|
||||||
|
if (_autoFishing) startFishing();
|
||||||
|
}, 5000);
|
||||||
|
if (autoScroll) container2.scrollTop = container2.scrollHeight;
|
||||||
|
return; // 阻止后续重置逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
_autoFishing = false; // 非自动模式出错时停止
|
||||||
}
|
}
|
||||||
if (autoScroll) container2.scrollTop = container2.scrollHeight;
|
if (autoScroll) container2.scrollTop = container2.scrollHeight;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// 网络断开或超时
|
||||||
|
if (_autoFishing) {
|
||||||
|
const noticeDiv = document.createElement('div');
|
||||||
|
noticeDiv.className = 'msg-line';
|
||||||
|
noticeDiv.innerHTML = `<span style="color:#d97706;">⚠️ 网络异常,5秒后自动重试钓鱼...</span>`;
|
||||||
|
container2.appendChild(noticeDiv);
|
||||||
|
if (autoScroll) container2.scrollTop = container2.scrollHeight;
|
||||||
|
|
||||||
|
const btn = document.getElementById('fishing-btn');
|
||||||
|
if (btn) {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.textContent = '⏳ 重试中...';
|
||||||
|
}
|
||||||
|
_autoFishCdTimer = setTimeout(() => {
|
||||||
|
_autoFishCdTimer = null;
|
||||||
|
if (_autoFishing) startFishing();
|
||||||
|
}, 5000);
|
||||||
|
return; // 阻止后续重置逻辑
|
||||||
|
}
|
||||||
|
|
||||||
window.chatDialog.alert('网络错误:' + e.message, '网络异常', '#cc4444');
|
window.chatDialog.alert('网络错误:' + e.message, '网络异常', '#cc4444');
|
||||||
_autoFishing = false;
|
_autoFishing = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user