diff --git a/docs/02-prd.md b/docs/02-prd.md index 41da57f..6829a23 100644 --- a/docs/02-prd.md +++ b/docs/02-prd.md @@ -260,6 +260,7 @@ - F 失败原因:留空(由 AI 穿搭写回) - **行数**:等于本次批量产出的有效印花子目录数(即目录内至少有一个合成图文件),按印花文件名字母序排列。 - 若本次批量无任何成功的印花子目录,则不生成 Excel。 +- Excel 生成后弹出信息框提示用户,内容包含文件路径和「可切换到 AI 穿搭页直接使用」的引导语;用户点击「确定」关闭。 - 用户在「AI 穿搭」页选择此 Excel,即可直接对合成图批量生成穿搭效果图(C 列为目录,触发目录扇出逻辑,详见 `docs/11-ai-outfit.md` §4.1 / §9.1)。 ## 7. 非功能需求 diff --git a/src/app/widgets/queue_panel.py b/src/app/widgets/queue_panel.py index 15a1ea9..f501a72 100644 --- a/src/app/widgets/queue_panel.py +++ b/src/app/widgets/queue_panel.py @@ -395,13 +395,25 @@ class QueuePanel(QWidget): self._running = False self._batch_btn.setText("开始批量导出") - self._write_outfit_excel(run_dir) + excel_path = self._write_outfit_excel(run_dir) + if excel_path: + from PySide6.QtWidgets import QMessageBox + QMessageBox.information( + self, + "AI 穿搭 Excel 已生成", + "已生成 AI 穿搭 Excel 文件:\n{}\n\n可切换到「AI 穿搭」页,选择该文件直接开始生成穿搭图。".format( + excel_path + ), + ) def _write_outfit_excel(self, run_dir): - """Generate an AI-outfit source Excel alongside *run_dir* (docs/02 §6.12).""" + """Generate an AI-outfit source Excel alongside *run_dir* (docs/02 §6.12). + + Returns the excel path string on success, None if skipped or failed. + """ run_path = Path(run_dir) if not run_path.is_dir(): - return + return None _img_exts = {".png", ".jpg", ".jpeg", ".webp", ".gif"} rows = [] for subdir in sorted(run_path.iterdir(), key=lambda p: p.name.lower()): @@ -410,12 +422,14 @@ class QueuePanel(QWidget): if any(f.suffix.lower() in _img_exts for f in subdir.iterdir() if f.is_file()): rows.append((subdir.name, str(subdir) + os.sep)) if not rows: - return + return None excel_path = run_path.with_suffix(".xlsx") try: write_outfit_source_excel(excel_path, rows) + return str(excel_path) except Exception as exc: logger.error("Failed to write outfit source Excel: %s", exc) + return None def _image_size(self, path): """Return (w, h) for path, caching within a run. None if unreadable.""" diff --git a/tasks.md b/tasks.md index 3c8aa48..b000f8f 100644 --- a/tasks.md +++ b/tasks.md @@ -1034,6 +1034,25 @@ - `write_outfit_source_excel` 生成的文件表头正确、行数 = 传入 rows 数、A/B/C 列值正确(A=print_name,B=空,C=subdir 末尾有 `/`)、D/E/F 为空 - [ ] 验收:批量导出完成后 `<合并后的图片>/` 下出现 `<时间戳>.xlsx`;打开 AI 穿搭、选该文件,预览下拉显示各印花名行(货号列显示「无货号」);「开始生成」触发目录扇出,正常输出穿搭图 +### 17.24 批量导出完成弹窗提示 AI 穿搭 Excel — docs/02 §6.12 + +前置阅读: + +- `docs/02-prd.md`(§6.12 AI 穿搭 Excel) +- `src/app/widgets/queue_panel.py`(`_start_batch`、`_write_outfit_excel`) + +背景: + +§17.23 已在批量导出完成后生成同名 xlsx,但用户感知不到。需在 Excel 成功生成后弹出信息框,告知文件路径并引导切换到「AI 穿搭」页使用。 + +任务: + +- [ ] `queue_panel.py`:`_write_outfit_excel` 成功生成 Excel 后返回 `excel_path`,失败/跳过返回 `None` +- [ ] `_start_batch` 拿到返回值后,若不为 `None`,调用 `QMessageBox.information` 弹出提示: + - 标题:`AI 穿搭 Excel 已生成` + - 内容:`已生成 AI 穿搭 Excel 文件:\n\n\n可切换到「AI 穿搭」页,选择该文件直接开始生成穿搭图。` +- [ ] 验收:批量导出完成后弹框显示 xlsx 路径;点「确定」关闭;若无有效印花子目录则不弹框 + ## 18. 后续暂缓任务 以下任务第一阶段暂不做,后续需要时再新增设计文档: