diff --git a/resources/views/chat/partials/games/fishing-panel.blade.php b/resources/views/chat/partials/games/fishing-panel.blade.php index 8051c1b..692a2f4 100644 --- a/resources/views/chat/partials/games/fishing-panel.blade.php +++ b/resources/views/chat/partials/games/fishing-panel.blade.php @@ -254,10 +254,46 @@ errDiv.innerHTML = `【钓鱼】${data.message || '操作失败'}(${timeStr})`; 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; } catch (e) { + // 网络断开或超时 + if (_autoFishing) { + const noticeDiv = document.createElement('div'); + noticeDiv.className = 'msg-line'; + noticeDiv.innerHTML = `⚠️ 网络异常,5秒后自动重试钓鱼...`; + 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'); _autoFishing = false; }