diff --git a/gui_app.py b/gui_app.py index 3623b4d..4d67b71 100644 --- a/gui_app.py +++ b/gui_app.py @@ -4120,7 +4120,7 @@ class MainWindow(QMainWindow): self._row_map_by_user_index = m def _on_worker_item_result(self, payload): - """接收自动化侧逐条结果 - 每处理完一条就立即更新状态和计数""" + """接收自动化侧逐条结果 - 仅用于 batch_video 类型任务的实时状态更新""" try: if not isinstance(payload, dict): return @@ -4133,6 +4133,13 @@ class MainWindow(QMainWindow): if not user_id: return + # 检查当前任务类型,只有 batch_video 类型才在这里更新计数 + # single_video 和 image_folder 类型在 _on_batch_task_finished 中更新 + is_batch_video_task = False + if hasattr(self, 'current_batch_task_index') and self.current_batch_task_index < len(self.batch_task_queue): + current_task = self.batch_task_queue[self.current_batch_task_index] + is_batch_video_task = current_task.get('type') == 'batch_video' + # 全局搜索匹配的多多ID和序号 found_config_idx = -1 updated_count = 0 # 记录更新了多少条配置 @@ -4143,9 +4150,9 @@ class MainWindow(QMainWindow): found_config_idx = i break - # 如果通过序号没找到,且批量上传模式下,尝试通过多多ID匹配所有相关配置 + # 如果通过序号没找到,尝试通过多多ID匹配 if found_config_idx == -1: - # 查找所有匹配多多ID的配置(批量上传时可能有多个配置对应同一个多多ID) + # 查找所有匹配多多ID的配置 matching_indices = [] for i, cfg in enumerate(self.configs): if str(cfg.get("多多id")) == user_id: @@ -4154,9 +4161,8 @@ class MainWindow(QMainWindow): # 如果只找到一个匹配的配置,直接使用它 if len(matching_indices) == 1: found_config_idx = matching_indices[0] - # 如果有多个匹配的配置,且当前正在执行批量任务,更新所有相关配置的状态 - elif len(matching_indices) > 1 and hasattr(self, 'current_batch_task_index') and self.current_batch_task_index < len(self.batch_task_queue): - # 获取当前任务的配置索引列表 + # 如果有多个匹配的配置,且是批量视频任务,更新相关配置的状态 + elif len(matching_indices) > 1 and is_batch_video_task: current_task = self.batch_task_queue[self.current_batch_task_index] task_config_indices = current_task.get('config_indices', []) # 只更新当前任务相关的配置状态 @@ -4167,7 +4173,7 @@ class MainWindow(QMainWindow): found_config_idx = -2 # 标记为已处理(多个配置) if found_config_idx >= 0: - # 单个配置匹配成功,更新状态 + # 单个配置匹配成功,更新表格状态 self._update_table_status(found_config_idx, "已完成" if ok else "失败", is_config_index=True) updated_count = 1 label = name if name else payload.get("path", "") or "" @@ -4179,8 +4185,9 @@ class MainWindow(QMainWindow): else: self.log_text.append(f"[结果] {user_id}-{idx}: ok={ok} {reason} (未在列表中找到匹配项)") - # 立即更新成功/失败计数和状态卡片(实时反馈) - if updated_count > 0: + # 只有 batch_video 类型任务才在这里更新计数(实时反馈) + # single_video 和 image_folder 在 _on_batch_task_finished 中更新,避免重复计数 + if is_batch_video_task and updated_count > 0: if ok: self.batch_success_count += updated_count else: