feat: add task workflow and asset downloads

This commit is contained in:
inman
2026-05-29 12:32:02 +08:00
parent f9c3393f84
commit 63e62d444c
61 changed files with 2773 additions and 2181 deletions

View File

@@ -1,7 +1,7 @@
import catalog from "@/runtime/nianxx-play/content/seedance-starter/catalog.json";
import catalog from "@/lib/content/seedance-starter/catalog.json";
type LegacyCatalog = typeof catalog;
type LegacyCase = LegacyCatalog["cases"][number];
type SeedanceCatalog = typeof catalog;
type SeedanceCase = SeedanceCatalog["cases"][number];
export type VideoTemplate = {
id: string;
@@ -24,26 +24,16 @@ export type VideoTemplate = {
};
export function getVideoTemplates(): VideoTemplate[] {
return (catalog.cases as LegacyCase[]).map((item) => ({
return (catalog.cases as SeedanceCase[]).map((item) => ({
id: item.id,
title: item.title,
mode: item.mode,
modeLabel: item.modeLabel,
prompt: item.prompt,
seedanceInstruction: typeof item.promptPattern?.seedanceInstruction === "string" ? item.promptPattern.seedanceInstruction : undefined,
coverUrl: rewriteLegacyUrl(item.display?.coverPublicUrl),
referenceVideoUrl: rewriteLegacyUrl(item.display?.referenceVideoPublicUrl),
resultVideoUrl: rewriteLegacyUrl(item.display?.resultVideoPublicUrl),
selectable: Boolean(item.display?.selectableAsReferenceTemplate),
controls: item.interactionHooks?.visibleControls || [],
materials: (item.assets || [])
.map((asset) => ({
role: asset.role,
type: asset.role.includes("video") ? "video" as const : asset.role.includes("audio") ? "audio" as const : "image" as const,
url: rewriteLegacyUrl(asset.publicUrl) || "",
label: "promptLabel" in asset ? asset.promptLabel : undefined
}))
.filter((asset) => asset.url)
materials: []
}));
}
@@ -51,10 +41,3 @@ export function getTemplateById(id?: string): VideoTemplate | undefined {
if (!id) return undefined;
return getVideoTemplates().find((template) => template.id === id);
}
function rewriteLegacyUrl(url?: string | null): string | undefined {
if (!url) return undefined;
if (/^https?:\/\//i.test(url)) return url;
if (url.startsWith("/seedance-starter-assets/") || url.startsWith("/starter/") || url.startsWith("/planning-cases/")) return url;
return url;
}