Files
NianAIGC/lib/content/video-templates.ts
2026-05-29 12:32:02 +08:00

44 lines
1.2 KiB
TypeScript

import catalog from "@/lib/content/seedance-starter/catalog.json";
type SeedanceCatalog = typeof catalog;
type SeedanceCase = SeedanceCatalog["cases"][number];
export type VideoTemplate = {
id: string;
title: string;
mode: string;
modeLabel: string;
prompt: string;
seedanceInstruction?: string;
coverUrl?: string;
referenceVideoUrl?: string;
resultVideoUrl?: string;
selectable: boolean;
controls: string[];
materials: Array<{
role: string;
type: "image" | "video" | "audio";
url: string;
label?: string;
}>;
};
export function getVideoTemplates(): VideoTemplate[] {
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,
selectable: Boolean(item.display?.selectableAsReferenceTemplate),
controls: item.interactionHooks?.visibleControls || [],
materials: []
}));
}
export function getTemplateById(id?: string): VideoTemplate | undefined {
if (!id) return undefined;
return getVideoTemplates().find((template) => template.id === id);
}