Browse Source

修复:研究完成后不再显示重新连接提示

userName 2 tháng trước cách đây
mục cha
commit
13909737ca
1 tập tin đã thay đổi với 14 bổ sung3 xóa
  1. 14 3
      lightstar-web/src/components/forms/research-form.tsx

+ 14 - 3
lightstar-web/src/components/forms/research-form.tsx

@@ -626,9 +626,15 @@ export function ResearchForm({ className = "", onSubmit }: ResearchFormProps) {
       eventSource.onerror = (error: Event) => {
         console.error("与研究服务连接失败:", error);
         
-        // 重连尝试计数
-        if (!window.sseRetryCount) {
-          window.sseRetryCount = 0;
+        // 检查研究是否已完成
+        if (researchCompleted) {
+          // 研究已完成,不再尝试重新连接,也不显示错误
+          try {
+            eventSource.close();
+          } catch (e) {
+            // 忽略关闭错误
+          }
+          return;
         }
         
         // 检查是否已完成大部分研究 (即已经生成了最后一个方向的报告)
@@ -663,6 +669,11 @@ export function ResearchForm({ className = "", onSubmit }: ResearchFormProps) {
           return;
         }
         
+        // 重连尝试计数 (仅在研究未完成时才尝试重连)
+        if (!window.sseRetryCount) {
+          window.sseRetryCount = 0;
+        }
+        
         // 增加重连机制 - 但只在未生成足够报告时尝试
         if (window.sseRetryCount < 3) {
           console.log(`尝试重新连接 (${window.sseRetryCount + 1}/3)...`);