Add built-in Cloud video template fallback
This commit is contained in:
@@ -224,6 +224,8 @@ function parseJsonInput(value: string, label: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const BUILTIN_CLOUD_TEMPLATE_VALUE = '__builtin_cloud_seedance__';
|
||||
|
||||
export default function MoneyPrinter() {
|
||||
const location = useLocation();
|
||||
const audience: SessionAudience = location.pathname.startsWith('/user/') ? 'user' : 'admin';
|
||||
@@ -271,15 +273,21 @@ export default function MoneyPrinter() {
|
||||
}, [loadJobs, loadWorkflows]);
|
||||
|
||||
const selectedWorkflow = workflows.find((item) => item.publicId === templateId) || null;
|
||||
const canSubmit = Boolean(topic.trim()) && !submitting && (videoBackend !== 'comfy' || Boolean(templateId));
|
||||
const useBuiltinCloudTemplate = videoBackend === 'comfy' && (!templateId || templateId === BUILTIN_CLOUD_TEMPLATE_VALUE);
|
||||
const canSubmit = Boolean(topic.trim()) && !submitting;
|
||||
|
||||
useEffect(() => {
|
||||
if (useBuiltinCloudTemplate) {
|
||||
setComfyPrompt('');
|
||||
setComfyNodeMapping('{\n "prompt": { "nodeId": "1", "field": "prompt" },\n "ratio": { "nodeId": "1", "field": "aspect_ratio" },\n "resolution": { "nodeId": "1", "field": "resolution" },\n "duration": { "nodeId": "1", "field": "duration" }\n}');
|
||||
return;
|
||||
}
|
||||
if (!selectedWorkflow || videoBackend !== 'comfy') return;
|
||||
const prompt = workflowPromptFromGraph(selectedWorkflow.graph);
|
||||
if (prompt) setComfyPrompt(JSON.stringify(prompt, null, 2));
|
||||
const mapping = mappingFromGraph(selectedWorkflow.graph);
|
||||
setComfyNodeMapping(JSON.stringify(mapping || inferMappingFromPrompt(prompt), null, 2));
|
||||
}, [selectedWorkflow?.publicId, videoBackend]);
|
||||
}, [selectedWorkflow?.publicId, videoBackend, useBuiltinCloudTemplate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!jobs.some((job) => !terminal(job.status))) return;
|
||||
@@ -309,8 +317,8 @@ export default function MoneyPrinter() {
|
||||
requirements,
|
||||
language: '中文',
|
||||
...(videoBackend === 'comfy' ? {
|
||||
templateId: templateId || undefined,
|
||||
comfyPrompt: parseJsonInput(comfyPrompt, 'Comfy prompt JSON'),
|
||||
templateId: useBuiltinCloudTemplate ? undefined : templateId,
|
||||
comfyPrompt: useBuiltinCloudTemplate ? undefined : parseJsonInput(comfyPrompt, 'Comfy prompt JSON'),
|
||||
comfyNodeMapping: parseJsonInput(comfyNodeMapping, '节点映射 JSON'),
|
||||
} : {}),
|
||||
});
|
||||
@@ -450,7 +458,7 @@ export default function MoneyPrinter() {
|
||||
<label className="money-printer-field">
|
||||
<span>工作流模板</span>
|
||||
<select value={templateId} onChange={(event) => setTemplateId(event.target.value)}>
|
||||
<option value="">请选择模板</option>
|
||||
<option value={BUILTIN_CLOUD_TEMPLATE_VALUE}>内置 Cloud Seedance 文生视频</option>
|
||||
{workflows.map((workflow) => (
|
||||
<option key={workflow.publicId} value={workflow.publicId}>
|
||||
{workflowLooksVideoCapable(workflow) ? '视频 · ' : '模板 · '}{workflowOptionLabel(workflow)}
|
||||
@@ -458,7 +466,12 @@ export default function MoneyPrinter() {
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{selectedWorkflow ? (
|
||||
{useBuiltinCloudTemplate ? (
|
||||
<div className="money-printer-template-meta">
|
||||
<strong>内置 Cloud Seedance 文生视频</strong>
|
||||
<span>无需导入模板,使用 Comfy Cloud 官方 ByteDanceTextToVideoNode。若账号无余额,会直接显示余额不足。</span>
|
||||
</div>
|
||||
) : selectedWorkflow ? (
|
||||
<div className="money-printer-template-meta">
|
||||
<strong>{selectedWorkflow.name}</strong>
|
||||
<span>
|
||||
|
||||
Reference in New Issue
Block a user