diff --git a/index.html b/index.html index 469153b..15cfe5d 100755 --- a/index.html +++ b/index.html @@ -1679,6 +1679,8 @@ const from = params.get("from"); let token = params.get("token");//app的token let localtoken = params.get("localtoken");//公众号的localtoken + + // app会得到token; // 手机端会验证token @@ -2565,20 +2567,65 @@ const getAiResponse = async (img) => { }); } catch (err) { loadingDiv.textContent = "请求中断"; + if (controller) { + controller.abort(); + controller = null; + } + sendBtnImg.classList.remove('none'); + stopBtn.forEach(e => { + e.classList.add('none') + }) return; } if (!res?.body) { loadingDiv.textContent = "无响应"; + document.querySelectorAll('.thinking-loading').forEach(el=>el.classList.add('no-after')); return; } + if (!res) { + + + if (sendBtnImg.classList.contains("none")) { + sendBtnImg.classList.remove('none'); + } + stopBtn.forEach(e => { + if (!e.classList.contains('none')) { + e.classList.add('none') + } + + }) + document.querySelectorAll('.thinking-loading').forEach(el=>el.classList.add('no-after')); + + return null; + } + if (res.status === 400) { + document.querySelectorAll('.thinking-loading').forEach(el=>el.classList.add('no-after')); + if (controller) { + controller.abort(); + controller = null; + } + if (sendBtnImg.classList.contains("none")) { + sendBtnImg.classList.remove('none'); + + } + stopBtn.forEach(e => { + if (!e.classList.contains("none")) { + e.classList.add('none') + } + }) + showpop(); + return; + } + // ========================= // SSE 读取 // ========================= const reader = res.body.getReader(); const decoder = new TextDecoder("utf-8"); let buffer = ""; + showPop(userId); while (true) { const { done, value } = await reader.read();