fix: resolve issue with image retry results not persisting after page refresh in the image workbench

This commit is contained in:
HouYunFei
2026-07-05 12:46:51 +08:00
parent 568f0f1838
commit 522153b3e6
3 changed files with 26 additions and 4 deletions
+1 -2
View File
@@ -3,8 +3,7 @@
## Unreleased
+ [新增] 新增Codex App插件支持。
+ [修复] 修复前端 TypeScript 构建报错
+ [调整] Docker 运行镜像改为 nginx 静态托管。
+ [修复] 修复生图工作台重试成功结果刷新后丢失的问题
## v0.5.0 - 2026-07-05
@@ -17,3 +17,4 @@ description: 当前版本已实现但仍需人工验证的变更项
- Vercel 部署:新增 `web` 和 `docs` 两个子项目的 Vercel 配置,需分别验证静态前端和文档站部署。
- Docker 部署:运行镜像从 Node serve 改为 nginx 静态托管,需验证前端路由刷新回退。
- 环境变量:移除过期的后端 `.env.example` 示例文件。
- 生图工作台:修复失败图片点击重试后只保存在页面状态、刷新或跳转后丢失的问题,重试成功结果会写入本地图片存储和生成记录。
+24 -2
View File
@@ -296,12 +296,34 @@ export default function ImagePage() {
}
};
const retryResult = (index: number) => {
const retryResult = async (index: number) => {
const snapshot = buildRequestSnapshot();
if (!snapshot) return;
setPreviewLog(null);
setResults((value) => updateResultAt(value, index, { status: "pending", error: undefined, image: undefined }));
void runGenerationSlot(index, snapshot).catch(() => {});
const retryStartedAt = performance.now();
try {
const image = await runGenerationSlot(index, snapshot);
const stored = await uploadImage(image.dataUrl);
const logImage = { ...image, dataUrl: stored.url, storageKey: stored.storageKey, width: stored.width, height: stored.height, bytes: stored.bytes, mimeType: stored.mimeType };
setResults((value) => updateResultAt(value, index, { image: { ...image, dataUrl: stored.url, storageKey: stored.storageKey } }));
saveLog(
buildLog({
prompt: snapshot.text,
model,
config: { ...snapshot.config, count: "1" },
references: snapshot.references,
durationMs: performance.now() - retryStartedAt,
successCount: 1,
failCount: 0,
status: "成功",
images: [logImage],
}),
);
message.success("重试成功");
} catch {
// runGenerationSlot 已经把结果状态更新为 failed
}
};
return (