feat: complete TASK-WP2-07 latest exports

This commit is contained in:
suyx
2026-08-03 01:43:09 +08:00
parent 2bb4f86d04
commit 1b0a05bbcf
20 changed files with 1791 additions and 18 deletions
+32
View File
@@ -0,0 +1,32 @@
export type ExportFlowStatus = "composition_failed" | "download_failed" | "downloaded_not_saved" | "downloaded_and_saved";
export const exportResultCopy: Record<ExportFlowStatus, string> = {
composition_failed: "合成失败,请返回编辑器检查",
download_failed: "浏览器下载失败,可重新下载同一次合成结果",
downloaded_not_saved: "文件已下载,但未保存为最新成品",
downloaded_and_saved: "已下载并保存为最新成品",
};
export async function runExportFlow(input: {
compose: () => Promise<Blob>;
download: (blob: Blob) => Promise<void>;
persist: (blob: Blob) => Promise<void>;
}): Promise<{ blob: Blob | null; status: ExportFlowStatus }> {
let blob: Blob;
try {
blob = await input.compose();
} catch {
return { blob: null, status: "composition_failed" };
}
try {
await input.download(blob);
} catch {
return { blob, status: "download_failed" };
}
try {
await input.persist(blob);
return { blob, status: "downloaded_and_saved" };
} catch {
return { blob, status: "downloaded_not_saved" };
}
}