chore: updates

This commit is contained in:
Tristan Yang
2024-04-16 10:32:03 +08:00
parent 86d06f9d82
commit 8d109a6635
6 changed files with 1081 additions and 1069 deletions
+10 -10
View File
@@ -88,12 +88,12 @@ export default function useStreaming() {
console.info("debug SSE: start new timeout", aliveInter);
};
const startStreaming = useCallback(async () => {
console.info("debug SSE: clear timeout at startStreaming", aliveInter);
clearTimeout(aliveInter);
if (SSE && (SSE.readyState === EventSource.OPEN || SSE.readyState === EventSource.CONNECTING)) {
console.info("debug SSE: SSE not disconnect");
return;
}
// stop first
stopStreaming();
// if (SSE && (SSE.readyState === EventSource.OPEN || SSE.readyState === EventSource.CONNECTING)) {
// console.info("debug SSE: SSE not disconnect");
// return;
// }
const { token, refreshToken, expireTime } = getLocalAuthData();
// token 非空
if (!token) {
@@ -107,10 +107,10 @@ export default function useStreaming() {
if ("error" in resp) {
console.error("renew error from sse", resp.error);
// 还有网,而且在当前页,则停止循环
const tabHidden = isTabHidden();
if (navigator.onLine || !tabHidden) {
stopStreaming();
}
// const tabHidden = isTabHidden();
// if (navigator.onLine || !tabHidden) {
// stopStreaming();
// }
// 返回,开始下次 polling(如果有)
return;
} else {