feat: bot setting

This commit is contained in:
Tristan Yang
2022-12-19 22:07:04 +08:00
parent e297411d00
commit 2b2cdf4df8
18 changed files with 934 additions and 497 deletions
+8 -5
View File
@@ -54,9 +54,12 @@ export default function useStreaming() {
window.clearTimeout(aliveInter);
// 比15秒多5秒
aliveInter = window.setTimeout(() => {
// 重启连接
stopStreaming();
startStreaming();
// 有网的情况再试
if (navigator.onLine) {
// 重启连接
stopStreaming();
startStreaming();
}
}, timeout ?? 20000);
};
const startStreaming = useCallback(
@@ -114,7 +117,7 @@ export default function useStreaming() {
return;
}
// 重连
connectionIsOpen = false;
// connectionIsOpen = false;
keepAlive(2000);
};
SSE.onmessage = (evt) => {
@@ -306,8 +309,8 @@ export default function useStreaming() {
if (SSE) {
SSE.close();
SSE = undefined;
connectionIsOpen = false;
}
connectionIsOpen = false;
};
useEffect(() => {