feat(studio): 三种图片输入工作流与最多九张参考图 (HEL-633)
- 解析:H3 参考生视频 ref_images 自增输入收拢为 1–9 张有序参考图组; 图生视频首/尾帧、Qwen 编辑输入图按真实连线识别,未连线不出槽位; Qwen 编辑模式暴露 resolution - 打补丁:按张数克隆/复用/删除 LoadImage 并按序接线 ref_image_0..N-1 - 校验:参考图上限 9、至少 1 张、格式/存在性;必填图片槽位 - 工作流体检:缺 class_type / 断链 / 采样器无模型 → 导入时中文告警, 生成接口与 worker 拒绝执行并提示重新导出 - 前端:RefImageGrid(逐张添加/预览/替换/删除/序号/超限整批拒绝)、 MediaSlot 横排已选态、分辨率字段、损坏工作流提示、连接页告警标签 - 测试:三份真实 JSON + 1/4/9 张参考图全链路 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
60c043db7c
commit
30e8e85766
@@ -2,22 +2,31 @@
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import Spinner from '$lib/components/ui/Spinner.svelte';
|
||||
import { assetUrl } from '$lib/api';
|
||||
import { IMAGE_SLOT_ACCEPT, formatBytes, uploadBaseName } from '$lib/comfy/imageFile';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
|
||||
/**
|
||||
* A-style media upload slot (spec-v2 §5 上传槽): empty = 1.5px dashed
|
||||
* border + "click or drop", drag-hover = amber dashed, filled = solid
|
||||
* border + thumbnail + mono name + ✕, error = red border + red reason.
|
||||
* A-style media upload slot (spec-v2 §5 上传槽, ref-upload-spec §2):
|
||||
* empty = 1.5px dashed border + "click or drop" + format line, drag-hover
|
||||
* = amber dashed, filled = solid border + thumb + name + size + 替换 + ✕,
|
||||
* error = red border + red reason.
|
||||
*/
|
||||
interface Props {
|
||||
label: string;
|
||||
/** Extra hint under the label, e.g. 可从生图结果送入. */
|
||||
/** Hint on the right of the label, e.g. 必填 · 1 张 / 可从生图结果送入. */
|
||||
hint?: string;
|
||||
required?: boolean;
|
||||
/** Current value: a server-side path ('' = empty). */
|
||||
value: string;
|
||||
kind: 'image' | 'video' | 'audio';
|
||||
/** Thumb aspect: wide = 16:9 (first/last frame slots). */
|
||||
aspect?: 'square' | 'wide';
|
||||
/** Empty-state main line (defaults to 点击或拖入). */
|
||||
emptyText?: string;
|
||||
/** Empty-state mono line, e.g. accepted formats and size limit. */
|
||||
emptySub?: string;
|
||||
/** Byte size of the current file when known. */
|
||||
size?: number;
|
||||
uploading?: boolean;
|
||||
uploadName?: string;
|
||||
error?: string;
|
||||
@@ -31,9 +40,13 @@
|
||||
let {
|
||||
label,
|
||||
hint,
|
||||
required = false,
|
||||
value,
|
||||
kind,
|
||||
aspect = 'square',
|
||||
emptyText,
|
||||
emptySub,
|
||||
size,
|
||||
uploading = false,
|
||||
uploadName,
|
||||
error,
|
||||
@@ -46,21 +59,24 @@
|
||||
let fileInput = $state<HTMLInputElement | null>(null);
|
||||
let dragDepth = $state(0);
|
||||
let broken = $state(false);
|
||||
let dims = $state('');
|
||||
$effect(() => {
|
||||
void value;
|
||||
broken = false;
|
||||
dims = '';
|
||||
});
|
||||
|
||||
const meta = $derived([dims, size != null ? formatBytes(size) : ''].filter(Boolean).join(' · '));
|
||||
|
||||
function accept(): string {
|
||||
if (kind === 'video') return 'video/*,.mp4,.webm,.mov,.mkv';
|
||||
if (kind === 'audio') return 'audio/*';
|
||||
return 'image/*';
|
||||
return IMAGE_SLOT_ACCEPT;
|
||||
}
|
||||
|
||||
function baseName(p: string): string {
|
||||
const raw = p.split(/[/\\]/).pop() ?? p;
|
||||
// strip uuid8- prefix the upload endpoint writes
|
||||
return /^[0-9a-f]{8}-/.test(raw) ? raw.slice(9) : raw;
|
||||
function noteDims(e: Event) {
|
||||
const img = e.currentTarget as HTMLImageElement;
|
||||
if (img.naturalWidth) dims = `${img.naturalWidth}×${img.naturalHeight}`;
|
||||
}
|
||||
|
||||
function pick() {
|
||||
@@ -80,7 +96,7 @@
|
||||
|
||||
<div class="media-slot" class:wide={aspect === 'wide'}>
|
||||
<div class="slot-label">
|
||||
<span class="lbl">{label}</span>
|
||||
<span class="lbl">{label}{#if required}<em>*</em>{/if}</span>
|
||||
{#if hint}<span class="slot-hint">{hint}</span>{/if}
|
||||
</div>
|
||||
|
||||
@@ -100,8 +116,10 @@
|
||||
{#if value && !broken}
|
||||
<div class="slot-filled" class:invalid={!!error}>
|
||||
<div class="slot-thumb">
|
||||
{#if kind === 'image'}
|
||||
<img src={assetUrl(value)} alt={label} onerror={() => (broken = true)} />
|
||||
{#if uploading}
|
||||
<Spinner size="sm" />
|
||||
{:else if kind === 'image'}
|
||||
<img src={assetUrl(value)} alt={label} onload={noteDims} onerror={() => (broken = true)} />
|
||||
{:else if kind === 'video'}
|
||||
<video src={assetUrl(value)} preload="metadata" muted></video>
|
||||
<span class="kind-badge" aria-hidden="true"><Icon name="film" size={12} /></span>
|
||||
@@ -110,22 +128,29 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="slot-meta">
|
||||
<span class="mono name" title={baseName(value)}>{baseName(value)}</span>
|
||||
<div class="slot-actions">
|
||||
{#if allowFromResults && onFromResults}
|
||||
<button type="button" class="mini-link" onclick={onFromResults}>
|
||||
{t('studio.slotFromResults')}
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
class="slot-clear"
|
||||
aria-label={t('studio.deleteBtn')}
|
||||
onclick={onClear}
|
||||
>
|
||||
<Icon name="close" size={13} />
|
||||
<span class="name" title={uploading ? uploadName : uploadBaseName(value)}>
|
||||
{uploading ? uploadName : uploadBaseName(value)}
|
||||
</span>
|
||||
{#if meta && !uploading}<span class="mono dims">{meta}</span>{/if}
|
||||
</div>
|
||||
<div class="slot-actions">
|
||||
{#if allowFromResults && onFromResults}
|
||||
<button type="button" class="mini-link" onclick={onFromResults}>
|
||||
{t('studio.slotFromResultsShort')}
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
<button type="button" class="mini-link" disabled={uploading} onclick={pick}>
|
||||
{t('studio.refReplace')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="slot-clear"
|
||||
aria-label={t('studio.deleteBtn')}
|
||||
disabled={uploading}
|
||||
onclick={onClear}
|
||||
>
|
||||
<Icon name="close" size={12} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
@@ -151,7 +176,8 @@
|
||||
<span class="pick-text">{uploadName ?? t('studio.slotPick')}</span>
|
||||
{:else}
|
||||
<Icon name={kind === 'video' ? 'film' : kind === 'audio' ? 'music' : 'image'} size={16} />
|
||||
<span class="pick-text">{t('studio.slotPick')}</span>
|
||||
<span class="pick-text">{emptyText ?? t('studio.slotPick')}</span>
|
||||
{#if emptySub}<span class="pick-sub mono">{emptySub}</span>{/if}
|
||||
{/if}
|
||||
</button>
|
||||
{#if allowFromResults && onFromResults}
|
||||
@@ -181,6 +207,11 @@
|
||||
font-weight: 600;
|
||||
color: var(--text-2);
|
||||
}
|
||||
.lbl em {
|
||||
color: var(--error);
|
||||
font-style: normal;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.slot-hint {
|
||||
font-size: 10.5px;
|
||||
color: var(--text-3);
|
||||
@@ -234,7 +265,12 @@
|
||||
opacity: 0.7;
|
||||
}
|
||||
.pick-text {
|
||||
font-size: 12.5px;
|
||||
color: var(--text-2);
|
||||
}
|
||||
.pick-sub {
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.from-results-link {
|
||||
align-self: flex-end;
|
||||
@@ -251,18 +287,21 @@
|
||||
}
|
||||
.slot-filled {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 8px;
|
||||
background: var(--surface-2);
|
||||
padding: 8px;
|
||||
}
|
||||
.slot-filled.invalid {
|
||||
border-color: rgba(229, 72, 77, 0.65);
|
||||
border-color: var(--error);
|
||||
}
|
||||
.slot-thumb {
|
||||
border-radius: 7px;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
@@ -271,39 +310,39 @@
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
}
|
||||
.media-slot.wide .slot-thumb {
|
||||
width: 88px;
|
||||
height: 50px;
|
||||
}
|
||||
.slot-thumb img,
|
||||
.slot-thumb video {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 140px;
|
||||
object-fit: cover;
|
||||
}
|
||||
.media-slot.wide .slot-thumb {
|
||||
aspect-ratio: 16 / 9;
|
||||
}
|
||||
.media-slot.wide .slot-thumb img,
|
||||
.media-slot.wide .slot-thumb video {
|
||||
max-height: none;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.slot-thumb .kind-badge {
|
||||
color: var(--text-3);
|
||||
}
|
||||
.slot-meta {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
.name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 10.5px;
|
||||
color: var(--text-3);
|
||||
font-size: 12.5px;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dims {
|
||||
font-size: 10.5px;
|
||||
color: var(--text-3);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.slot-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -315,12 +354,17 @@
|
||||
border: none;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
font-size: 10.5px;
|
||||
color: var(--accent);
|
||||
font-size: 11.5px;
|
||||
color: var(--text-2);
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mini-link:hover {
|
||||
text-decoration: underline;
|
||||
.mini-link:hover:not(:disabled) {
|
||||
color: var(--accent);
|
||||
}
|
||||
.mini-link:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
.slot-clear {
|
||||
display: inline-flex;
|
||||
@@ -330,7 +374,7 @@
|
||||
height: 22px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
background: var(--surface-3);
|
||||
color: var(--text-3);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,446 @@
|
||||
<script lang="ts">
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import Spinner from '$lib/components/ui/Spinner.svelte';
|
||||
import { assetUrl } from '$lib/api';
|
||||
import { IMAGE_SLOT_ACCEPT, formatBytes, uploadBaseName } from '$lib/comfy/imageFile';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
|
||||
/**
|
||||
* Reference-image grid (ref-upload-spec §2 `.refgrid`): numbered cells
|
||||
* 参考图 1…N in the order they reach the workflow, each with replace and
|
||||
* ✕; a dashed add cell while below `max`; rejected files show as error
|
||||
* cells that take no place in the list.
|
||||
*/
|
||||
interface Reject {
|
||||
name: string;
|
||||
message: string;
|
||||
}
|
||||
interface Props {
|
||||
label: string;
|
||||
paths: string[];
|
||||
max: number;
|
||||
/** Byte sizes of files uploaded in this session, by server path. */
|
||||
sizes?: Record<string, number>;
|
||||
/** Name of the file being uploaded (add or replace), if any. */
|
||||
uploadingName?: string;
|
||||
/** Index being replaced while uploading (-1 = adding). */
|
||||
uploadingIndex?: number;
|
||||
rejects?: Reject[];
|
||||
error?: string;
|
||||
allowFromResults?: boolean;
|
||||
onAdd: (files: File[]) => void;
|
||||
onReplace: (index: number, file: File) => void;
|
||||
onRemove: (index: number) => void;
|
||||
onDismissReject: (index: number) => void;
|
||||
onFromResults?: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
label,
|
||||
paths,
|
||||
max,
|
||||
sizes = {},
|
||||
uploadingName,
|
||||
uploadingIndex = -1,
|
||||
rejects = [],
|
||||
error,
|
||||
allowFromResults = false,
|
||||
onAdd,
|
||||
onReplace,
|
||||
onRemove,
|
||||
onDismissReject,
|
||||
onFromResults,
|
||||
}: Props = $props();
|
||||
|
||||
let addInput = $state<HTMLInputElement | null>(null);
|
||||
let replaceInput = $state<HTMLInputElement | null>(null);
|
||||
let replaceIndex = $state(-1);
|
||||
let dragDepth = $state(0);
|
||||
let dims = $state<Record<string, string>>({});
|
||||
|
||||
const uploading = $derived(!!uploadingName);
|
||||
const remaining = $derived(Math.max(0, max - paths.length));
|
||||
|
||||
function pickAdd() {
|
||||
if (uploading || !addInput) return;
|
||||
addInput.value = '';
|
||||
addInput.click();
|
||||
}
|
||||
|
||||
function pickReplace(i: number) {
|
||||
if (uploading || !replaceInput) return;
|
||||
replaceIndex = i;
|
||||
replaceInput.value = '';
|
||||
replaceInput.click();
|
||||
}
|
||||
|
||||
function onDrop(e: DragEvent) {
|
||||
e.preventDefault();
|
||||
dragDepth = 0;
|
||||
if (uploading) return;
|
||||
const files = Array.from(e.dataTransfer?.files ?? []);
|
||||
if (files.length) onAdd(files);
|
||||
}
|
||||
|
||||
function noteDims(path: string, e: Event) {
|
||||
const img = e.currentTarget as HTMLImageElement;
|
||||
if (img.naturalWidth) dims = { ...dims, [path]: `${img.naturalWidth}×${img.naturalHeight}` };
|
||||
}
|
||||
|
||||
function metaOf(path: string): string {
|
||||
return [dims[path], sizes[path] != null ? formatBytes(sizes[path]) : null].filter(Boolean).join(' · ');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="refgrid-field">
|
||||
<div class="slot-label">
|
||||
<span class="lbl">{label}<em>*</em></span>
|
||||
<span class="slot-hint">{t('studio.refHint', { n: paths.length, max })}</span>
|
||||
</div>
|
||||
|
||||
<input
|
||||
bind:this={addInput}
|
||||
type="file"
|
||||
class="sr-file"
|
||||
tabindex="-1"
|
||||
aria-hidden="true"
|
||||
accept={IMAGE_SLOT_ACCEPT}
|
||||
multiple
|
||||
onchange={(e) => {
|
||||
const files = Array.from(e.currentTarget.files ?? []);
|
||||
if (files.length) onAdd(files);
|
||||
}}
|
||||
/>
|
||||
<input
|
||||
bind:this={replaceInput}
|
||||
type="file"
|
||||
class="sr-file"
|
||||
tabindex="-1"
|
||||
aria-hidden="true"
|
||||
accept={IMAGE_SLOT_ACCEPT}
|
||||
onchange={(e) => {
|
||||
const f = e.currentTarget.files?.[0];
|
||||
if (f && replaceIndex >= 0) onReplace(replaceIndex, f);
|
||||
}}
|
||||
/>
|
||||
|
||||
<div class="refgrid">
|
||||
{#each paths as path, i (path + i)}
|
||||
<div class="ref-cell" class:busy={uploadingIndex === i}>
|
||||
<button
|
||||
type="button"
|
||||
class="ref-thumb"
|
||||
title={t('studio.refReplace')}
|
||||
onclick={() => pickReplace(i)}
|
||||
>
|
||||
<img src={assetUrl(path)} alt={t('studio.slotRefN', { n: i + 1 })} onload={(e) => noteDims(path, e)} />
|
||||
<span class="ref-no mono">{i + 1}</span>
|
||||
{#if uploadingIndex === i}
|
||||
<span class="ref-busy"><Spinner size="sm" /></span>
|
||||
{/if}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="ref-x"
|
||||
aria-label={t('studio.refRemove', { n: i + 1 })}
|
||||
onclick={() => onRemove(i)}
|
||||
>
|
||||
<Icon name="close" size={11} />
|
||||
</button>
|
||||
<span class="ref-name" title={uploadBaseName(path)}>{uploadBaseName(path)}</span>
|
||||
<span class="ref-meta mono">
|
||||
{metaOf(path)}
|
||||
<button type="button" class="mini-link" onclick={() => pickReplace(i)}>{t('studio.refReplace')}</button>
|
||||
</span>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
{#each rejects as rej, i (rej.name + i)}
|
||||
<div class="ref-cell rejected" role="alert">
|
||||
<div class="ref-thumb error">
|
||||
<Icon name="close" size={16} />
|
||||
<span class="mono">{t('studio.refRejectedShort')}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="ref-x"
|
||||
aria-label={t('studio.deleteBtn')}
|
||||
onclick={() => onDismissReject(i)}
|
||||
>
|
||||
<Icon name="close" size={11} />
|
||||
</button>
|
||||
<span class="ref-name err" title={rej.name}>{rej.name}</span>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
{#if remaining > 0}
|
||||
<button
|
||||
type="button"
|
||||
class="ref-add"
|
||||
class:drag={dragDepth > 0}
|
||||
class:invalid={!!error}
|
||||
disabled={uploading}
|
||||
aria-busy={uploading || undefined}
|
||||
onclick={pickAdd}
|
||||
ondragenter={(e) => {
|
||||
e.preventDefault();
|
||||
dragDepth += 1;
|
||||
}}
|
||||
ondragleave={() => (dragDepth = Math.max(0, dragDepth - 1))}
|
||||
ondragover={(e) => e.preventDefault()}
|
||||
ondrop={onDrop}
|
||||
>
|
||||
{#if uploading && uploadingIndex < 0}
|
||||
<Spinner size="sm" />
|
||||
<span class="add-main">{uploadingName}</span>
|
||||
{:else}
|
||||
<Icon name="plus" size={16} />
|
||||
<span class="add-main">{t('studio.refAdd')}</span>
|
||||
<span class="add-sub mono">{t('studio.refAddSub', { n: remaining, max })}</span>
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if allowFromResults && onFromResults && remaining > 0}
|
||||
<button type="button" class="from-results-link" onclick={onFromResults}>
|
||||
{t('studio.slotFromResults')}
|
||||
</button>
|
||||
{/if}
|
||||
{#if remaining === 0}
|
||||
<span class="full-note">{t('studio.refFull', { max })}</span>
|
||||
{/if}
|
||||
{#each rejects as rej, i (rej.name + i)}
|
||||
<span class="slot-error">{rej.message}</span>
|
||||
{/each}
|
||||
{#if error?.trim()}<span class="slot-error" role="alert">{error}</span>{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.refgrid-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.slot-label {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.lbl {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-2);
|
||||
}
|
||||
.lbl em {
|
||||
color: var(--error);
|
||||
font-style: normal;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.slot-hint {
|
||||
font-size: 10.5px;
|
||||
color: var(--text-3);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.sr-file {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
.refgrid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.ref-cell {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
padding: 5px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 8px;
|
||||
background: var(--surface-2);
|
||||
}
|
||||
.ref-cell.rejected {
|
||||
border-color: var(--error);
|
||||
}
|
||||
.ref-thumb {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
aspect-ratio: 1;
|
||||
padding: 0;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
background: var(--bg);
|
||||
cursor: pointer;
|
||||
}
|
||||
.ref-thumb img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.ref-thumb.error {
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
cursor: default;
|
||||
color: var(--error);
|
||||
font-size: 10px;
|
||||
}
|
||||
.ref-no {
|
||||
position: absolute;
|
||||
left: 4px;
|
||||
top: 4px;
|
||||
min-width: 16px;
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 0, 0, 0.62);
|
||||
color: var(--text);
|
||||
font-size: 10px;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
.ref-busy {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.ref-x {
|
||||
position: absolute;
|
||||
top: 9px;
|
||||
right: 9px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: rgba(0, 0, 0, 0.62);
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
}
|
||||
.ref-x:hover {
|
||||
color: var(--error);
|
||||
}
|
||||
.ref-name {
|
||||
font-size: 11px;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.ref-name.err {
|
||||
color: var(--error);
|
||||
}
|
||||
.ref-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 4px;
|
||||
font-size: 9.5px;
|
||||
color: var(--text-3);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.mini-link {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
font-size: 10.5px;
|
||||
color: var(--text-2);
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.mini-link:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.ref-add {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
min-height: 110px;
|
||||
padding: 8px 4px;
|
||||
border: 1.5px dashed var(--border-strong);
|
||||
border-radius: 8px;
|
||||
background: var(--surface-2);
|
||||
color: var(--text-3);
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 150ms,
|
||||
color 150ms;
|
||||
}
|
||||
.ref-add:hover:not(:disabled) {
|
||||
color: var(--text-2);
|
||||
}
|
||||
.ref-add.drag {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
.ref-add.invalid {
|
||||
border-color: var(--error);
|
||||
}
|
||||
.ref-add:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.add-main {
|
||||
font-size: 12px;
|
||||
color: var(--text-2);
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
}
|
||||
.add-sub {
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.from-results-link {
|
||||
align-self: flex-end;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
color: var(--accent);
|
||||
cursor: pointer;
|
||||
}
|
||||
.from-results-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.full-note {
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.slot-error {
|
||||
font-size: 11.5px;
|
||||
color: var(--error);
|
||||
line-height: 1.5;
|
||||
}
|
||||
@media (max-width: 1023px) {
|
||||
.refgrid {
|
||||
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -6,6 +6,8 @@
|
||||
import Modal from '$lib/components/ui/Modal.svelte';
|
||||
import ImageLightbox from '$lib/components/ImageLightbox.svelte';
|
||||
import MediaSlot from '$lib/components/studio/MediaSlot.svelte';
|
||||
import RefImageGrid from '$lib/components/studio/RefImageGrid.svelte';
|
||||
import { imageFileProblem } from '$lib/comfy/imageFile';
|
||||
import { toStore } from 'svelte/store';
|
||||
import { tick } from 'svelte';
|
||||
import AppShell from '$lib/components/shell/AppShell.svelte';
|
||||
@@ -123,7 +125,14 @@
|
||||
let endpointTouched = $state(false);
|
||||
let endpointId = $state('');
|
||||
let workflowId = $state<number | null>(null);
|
||||
let values = $state<Record<string, string | number>>({});
|
||||
type FormValue = string | number | string[];
|
||||
let values = $state<Record<string, FormValue>>({});
|
||||
/** Per-slot rejected picks (format / size) — shown in place, never uploaded. */
|
||||
let slotRejects = $state<Record<string, Array<{ name: string; message: string }>>>({});
|
||||
/** Byte size of files uploaded here, by server path (for the slot meta line). */
|
||||
let fileSizes = $state<Record<string, number>>({});
|
||||
/** Reference index being replaced while its upload runs. */
|
||||
let replacingIndex = $state(-1);
|
||||
let showErrors = $state(false);
|
||||
let submitting = $state(false);
|
||||
let lightboxOpen = $state(false);
|
||||
@@ -163,13 +172,14 @@
|
||||
}
|
||||
if (wf.id === lastWfId) return;
|
||||
lastWfId = wf.id;
|
||||
const next: Record<string, string | number> = {};
|
||||
const next: Record<string, FormValue> = {};
|
||||
for (const inp of wf.input_schema ?? []) {
|
||||
if (inp.defaultValue !== undefined && inp.defaultValue !== '') {
|
||||
next[inp.nodeId] = inp.defaultValue;
|
||||
}
|
||||
}
|
||||
values = next;
|
||||
slotRejects = {};
|
||||
showErrors = false;
|
||||
});
|
||||
|
||||
@@ -186,13 +196,36 @@
|
||||
return `${inp.role ?? ''} ${inp.label}`.toLowerCase();
|
||||
}
|
||||
const isMedia = (inp: ComfyDynamicInput) =>
|
||||
inp.kind === 'image' || inp.kind === 'image_url' || inp.kind === 'video' || inp.kind === 'audio';
|
||||
inp.kind === 'image' ||
|
||||
inp.kind === 'image_url' ||
|
||||
inp.kind === 'video' ||
|
||||
inp.kind === 'audio' ||
|
||||
inp.kind === 'image_list';
|
||||
// Auto-detected slots carry their role from the wiring; tagged (Input:…)
|
||||
// workflows still name frames only in the title.
|
||||
const isFirstFrame = (inp: ComfyDynamicInput) =>
|
||||
role(inp) === 'first_frame' || (!inp.auto && kind === 'video' && /first|start|首帧/.test(hay(inp)));
|
||||
const isLastFrame = (inp: ComfyDynamicInput) =>
|
||||
role(inp) === 'last_frame' || (!inp.auto && kind === 'video' && /last|end|尾帧/.test(hay(inp)));
|
||||
|
||||
// ComfyUI Autogrow reference images (H3 ref_images): one ordered 1…max list.
|
||||
const refGroup = $derived(schema.find((i) => i.kind === 'image_list') ?? null);
|
||||
const refMax = $derived(refGroup?.max ?? 9);
|
||||
const refPaths = $derived.by(() => {
|
||||
const v = refGroup ? values[refGroup.nodeId] : undefined;
|
||||
if (Array.isArray(v)) return v;
|
||||
return typeof v === 'string' && v ? [v] : [];
|
||||
});
|
||||
const brokenReasons = $derived(
|
||||
(currentWorkflow?.warnings ?? []).filter((w) => w.level === 'error').map((w) => w.message),
|
||||
);
|
||||
|
||||
const promptInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'prompt') ?? null);
|
||||
const negInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'negative') ?? null);
|
||||
const seedInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'seed') ?? null);
|
||||
const widthInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'width') ?? null);
|
||||
const heightInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'height') ?? null);
|
||||
const resolutionInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'resolution') ?? null);
|
||||
const durationInp = $derived(schema.find((i) => !isMedia(i) && role(i) === 'duration') ?? null);
|
||||
const stepsInp = $derived(schema.find((i) => /步数|steps/.test(hay(i)) && !isMedia(i)) ?? null);
|
||||
const cfgInp = $derived(
|
||||
@@ -220,38 +253,80 @@
|
||||
mediaKind: 'image' | 'video' | 'audio';
|
||||
aspect: 'square' | 'wide';
|
||||
fromResults: boolean;
|
||||
/** Required-slot message when left empty (ref-upload-spec §3). */
|
||||
missing: string;
|
||||
emptyText?: string;
|
||||
}
|
||||
|
||||
const mediaSlots = $derived.by(() => {
|
||||
const media = schema.filter(isMedia);
|
||||
const media = schema.filter((i) => isMedia(i) && i.kind !== 'image_list');
|
||||
const plainImages = media.filter(
|
||||
(i) => i.kind === 'image' && role(i) !== 'mask' && !/mask|遮罩/.test(hay(i)) && !isFirstFrame(i) && !isLastFrame(i),
|
||||
);
|
||||
const editInput = kind === 'image' && plainImages.length === 1 ? plainImages[0] : null;
|
||||
const out: SlotDef[] = [];
|
||||
let refIdx = 0;
|
||||
for (const inp of media) {
|
||||
const h = hay(inp);
|
||||
const base = { inp, missing: '' };
|
||||
if (inp.kind === 'video') {
|
||||
out.push({ inp, label: t('studio.slotRefVideo'), mediaKind: 'video', aspect: 'square', fromResults: false });
|
||||
out.push({ ...base, label: t('studio.slotRefVideo'), mediaKind: 'video', aspect: 'square', fromResults: false });
|
||||
} else if (inp.kind === 'audio') {
|
||||
out.push({ inp, label: t('studio.slotAudio'), mediaKind: 'audio', aspect: 'square', fromResults: false });
|
||||
} else if (/mask|遮罩/.test(h)) {
|
||||
out.push({ inp, label: t('studio.slotMask'), mediaKind: 'image', aspect: 'square', fromResults: false });
|
||||
} else if (kind === 'video' && /first|start|首帧/.test(h)) {
|
||||
out.push({ inp, label: t('studio.slotFirst'), mediaKind: 'image', aspect: 'wide', fromResults: true });
|
||||
} else if (kind === 'video' && /last|end|尾帧/.test(h)) {
|
||||
out.push({ inp, label: t('studio.slotLast'), mediaKind: 'image', aspect: 'wide', fromResults: true });
|
||||
out.push({ ...base, label: t('studio.slotAudio'), mediaKind: 'audio', aspect: 'square', fromResults: false });
|
||||
} else if (role(inp) === 'mask' || /mask|遮罩/.test(h)) {
|
||||
out.push({ ...base, label: t('studio.slotMask'), mediaKind: 'image', aspect: 'square', fromResults: false });
|
||||
} else if (isFirstFrame(inp)) {
|
||||
out.push({
|
||||
...base,
|
||||
label: t('studio.slotFirst'),
|
||||
mediaKind: 'image',
|
||||
aspect: 'wide',
|
||||
fromResults: true,
|
||||
missing: t('studio.errNeedFirstFrame'),
|
||||
emptyText: t('studio.slotEmptyFirst'),
|
||||
});
|
||||
} else if (isLastFrame(inp)) {
|
||||
out.push({ ...base, label: t('studio.slotLast'), mediaKind: 'image', aspect: 'wide', fromResults: true });
|
||||
} else if (inp === editInput) {
|
||||
out.push({
|
||||
...base,
|
||||
label: t('studio.slotInput'),
|
||||
mediaKind: 'image',
|
||||
aspect: 'square',
|
||||
fromResults: false,
|
||||
missing: t('studio.errNeedInputImage'),
|
||||
emptyText: t('studio.slotEmptyInput'),
|
||||
});
|
||||
} else {
|
||||
refIdx += 1;
|
||||
const label = inp.auto
|
||||
? inp.label
|
||||
: refIdx === 1 && media.length === 1
|
||||
? t('studio.slotRef')
|
||||
: t('studio.slotRefN', { n: refIdx });
|
||||
out.push({
|
||||
inp,
|
||||
label: refIdx === 1 && media.length === 1 ? t('studio.slotRef') : t('studio.slotRefN', { n: refIdx }),
|
||||
...base,
|
||||
label,
|
||||
mediaKind: 'image',
|
||||
aspect: kind === 'video' ? 'wide' : 'square',
|
||||
fromResults: kind === 'video',
|
||||
missing: t('studio.errUpload', { label }),
|
||||
});
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
/** Mode badge from what the workflow really wires (spec §1 table). */
|
||||
const modeLabel = $derived.by(() => {
|
||||
if (refGroup) return t('studio.modeRefToVideo');
|
||||
if (mediaSlots.some((s) => isFirstFrame(s.inp))) return t('studio.modeImageToVideo');
|
||||
if (kind === 'image' && mediaSlots.some((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask'))
|
||||
return t('studio.modeImageEdit');
|
||||
if (mediaSlots.length) return mediaSlots.map((s) => s.label).join(' · ');
|
||||
return kind === 'image' ? t('studio.modeTextToImage') : t('studio.modeTextToVideo');
|
||||
});
|
||||
|
||||
const structuredIds = $derived(
|
||||
new Set(
|
||||
[
|
||||
@@ -260,6 +335,7 @@
|
||||
seedInp,
|
||||
widthInp,
|
||||
heightInp,
|
||||
resolutionInp,
|
||||
durationInp,
|
||||
stepsInp,
|
||||
cfgInp,
|
||||
@@ -314,8 +390,9 @@
|
||||
if (!v.trim()) errs[promptInp.nodeId] = t('studio.errPrompt');
|
||||
else if (v.length > 2000) errs[promptInp.nodeId] = t('studio.errPromptLong');
|
||||
}
|
||||
const first = mediaSlots.find((s) => /first|start|首帧/.test(hay(s.inp)));
|
||||
const last = mediaSlots.find((s) => /last|end|尾帧/.test(hay(s.inp)));
|
||||
if (brokenReasons.length) errs.workflow = t('studio.errWfBroken');
|
||||
const first = mediaSlots.find((s) => isFirstFrame(s.inp));
|
||||
const last = mediaSlots.find((s) => isLastFrame(s.inp));
|
||||
if (first && last) {
|
||||
const a = String(values[first.inp.nodeId] ?? '');
|
||||
const b = String(values[last.inp.nodeId] ?? '');
|
||||
@@ -328,14 +405,14 @@
|
||||
for (const s of mediaSlots) {
|
||||
if (!s.inp.required) continue;
|
||||
if (!String(values[s.inp.nodeId] ?? '').trim()) {
|
||||
const isPlainRef = kind === 'image' && !/mask|遮罩|first|start|首帧|last|end|尾帧/.test(hay(s.inp));
|
||||
errs[s.inp.nodeId] =
|
||||
mediaSlots.filter((x) => x.mediaKind === 'image' && !/mask|遮罩/.test(hay(x.inp))).length === 1 &&
|
||||
isPlainRef
|
||||
? t('studio.errRefImage')
|
||||
: t('studio.errUpload', { label: s.label });
|
||||
errs[s.inp.nodeId] = s.missing || t('studio.errUpload', { label: s.label });
|
||||
}
|
||||
}
|
||||
if (refGroup) {
|
||||
if (refPaths.length < (refGroup.min ?? 1)) errs[refGroup.nodeId] = t('studio.errNeedRef');
|
||||
else if (refPaths.length > refMax)
|
||||
errs[refGroup.nodeId] = t('studio.errRefMax', { max: refMax, n: refPaths.length, k: refPaths.length - refMax });
|
||||
}
|
||||
for (const inp of restInputs) {
|
||||
if (inp.required && !String(values[inp.nodeId] ?? '').trim()) {
|
||||
errs[inp.nodeId] = t('studio.errFill', { label: inp.label });
|
||||
@@ -343,7 +420,7 @@
|
||||
}
|
||||
for (const inp of schema) {
|
||||
const raw = values[inp.nodeId];
|
||||
if (raw === undefined || String(raw).trim() === '' || errs[inp.nodeId]) continue;
|
||||
if (raw === undefined || Array.isArray(raw) || String(raw).trim() === '' || errs[inp.nodeId]) continue;
|
||||
const msg = valueError(inp, raw);
|
||||
if (msg) errs[inp.nodeId] = msg;
|
||||
}
|
||||
@@ -367,7 +444,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
function setVal(nodeId: string, v: string | number) {
|
||||
function setVal(nodeId: string, v: FormValue) {
|
||||
values = { ...values, [nodeId]: v };
|
||||
}
|
||||
function numVal(nodeId: string, raw: string) {
|
||||
@@ -382,11 +459,72 @@
|
||||
// ------------------------------------------------------------------
|
||||
// Uploads & media slots
|
||||
// ------------------------------------------------------------------
|
||||
async function slotFile(nodeId: string, file: File) {
|
||||
function setRejects(nodeId: string, list: Array<{ name: string; message: string }>) {
|
||||
slotRejects = { ...slotRejects, [nodeId]: list };
|
||||
}
|
||||
|
||||
async function uploadImage(nodeId: string, file: File): Promise<string | null> {
|
||||
const path = await uploads.uploadSafe(nodeId, file);
|
||||
if (path) fileSizes = { ...fileSizes, [path]: file.size };
|
||||
return path;
|
||||
}
|
||||
|
||||
async function slotFile(nodeId: string, file: File, mediaKind: 'image' | 'video' | 'audio' = 'image') {
|
||||
if (mediaKind === 'image') {
|
||||
const problem = imageFileProblem(file);
|
||||
if (problem) {
|
||||
setRejects(nodeId, [{ name: file.name, message: problem }]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setRejects(nodeId, []);
|
||||
const path = await uploadImage(nodeId, file);
|
||||
if (path) setVal(nodeId, path);
|
||||
}
|
||||
|
||||
/** Add picked/dropped files in order; a batch that would pass `max` is refused whole. */
|
||||
async function refAdd(files: File[]) {
|
||||
if (!refGroup) return;
|
||||
const key = refGroup.nodeId;
|
||||
const ok = files.filter((f) => !imageFileProblem(f));
|
||||
const rejected = files
|
||||
.filter((f) => imageFileProblem(f))
|
||||
.map((f) => ({ name: f.name, message: imageFileProblem(f)! }));
|
||||
setRejects(key, rejected);
|
||||
if (refPaths.length + ok.length > refMax) {
|
||||
toast.error(t('studio.errRefMax', { max: refMax, n: refPaths.length, k: ok.length }));
|
||||
return;
|
||||
}
|
||||
for (const f of ok) {
|
||||
const path = await uploadImage(key, f);
|
||||
if (!path) break;
|
||||
setVal(key, [...refPaths, path]);
|
||||
}
|
||||
}
|
||||
|
||||
async function refReplace(index: number, file: File) {
|
||||
if (!refGroup) return;
|
||||
const key = refGroup.nodeId;
|
||||
const problem = imageFileProblem(file);
|
||||
if (problem) {
|
||||
setRejects(key, [{ name: file.name, message: problem }]);
|
||||
return;
|
||||
}
|
||||
setRejects(key, []);
|
||||
replacingIndex = index;
|
||||
try {
|
||||
const path = await uploadImage(key, file);
|
||||
if (path) setVal(key, refPaths.map((p, i) => (i === index ? path : p)));
|
||||
} finally {
|
||||
replacingIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
function refRemove(index: number) {
|
||||
if (!refGroup) return;
|
||||
setVal(refGroup.nodeId, refPaths.filter((_, i) => i !== index));
|
||||
}
|
||||
|
||||
const imageResults = $derived(
|
||||
allJobs
|
||||
.filter((j) => j.kind === 'image' && jobStatusInfo(j).tone === 'ok')
|
||||
@@ -398,13 +536,18 @@
|
||||
pickerFor = nodeId;
|
||||
}
|
||||
function pickImageResult(path: string) {
|
||||
if (pickerFor) setVal(pickerFor, path);
|
||||
if (pickerFor && refGroup && pickerFor === refGroup.nodeId) {
|
||||
if (refPaths.length >= refMax) toast.error(t('studio.refFull', { max: refMax }));
|
||||
else setVal(pickerFor, [...refPaths, path]);
|
||||
} else if (pickerFor) {
|
||||
setVal(pickerFor, path);
|
||||
}
|
||||
pickerFor = null;
|
||||
}
|
||||
|
||||
function sendToImg2Img(path: string) {
|
||||
let wf = currentWorkflow;
|
||||
let target = mediaSlots.find((s) => s.mediaKind === 'image')?.inp ?? null;
|
||||
let target = mediaSlots.find((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask')?.inp ?? null;
|
||||
if (!target) {
|
||||
const candidate = ($workflowsQuery.data ?? []).find(
|
||||
(w) => w.kind === 'image' && w.is_enabled && (w.input_schema ?? []).some(isMedia),
|
||||
@@ -629,16 +772,24 @@
|
||||
const wf = ($workflowsQuery.data ?? []).find((w) => w.id === selectedEntry.job.workflow_id);
|
||||
if (!wf) return [];
|
||||
const vals = (selectedEntry.job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||||
const out: Array<{ label: string; path: string }> = [];
|
||||
const out: Array<{ label: string; path: string; ref?: boolean }> = [];
|
||||
for (const inp of wf.input_schema ?? []) {
|
||||
const h = `${inp.role ?? ''} ${inp.label}`.toLowerCase();
|
||||
const v = vals[inp.nodeId];
|
||||
if (inp.kind === 'image_list') {
|
||||
const list = Array.isArray(v) ? v : typeof v === 'string' && v ? [v] : [];
|
||||
list.forEach((p, i) => {
|
||||
if (typeof p === 'string') out.push({ label: t('studio.slotRefN', { n: i + 1 }), path: p, ref: true });
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (typeof v !== 'string' || !v) continue;
|
||||
if (/first|start|首帧/.test(h)) out.push({ label: t('studio.slotFirst'), path: v });
|
||||
else if (/last|end|尾帧/.test(h)) out.push({ label: t('studio.slotLast'), path: v });
|
||||
}
|
||||
return out;
|
||||
});
|
||||
const selectedRefCount = $derived(selectedFrames.filter((f) => f.ref).length);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// History actions
|
||||
@@ -650,14 +801,16 @@
|
||||
toast.error(t('studio.reuseMissingWf'));
|
||||
return;
|
||||
}
|
||||
const next: Record<string, string | number> = {};
|
||||
const next: Record<string, FormValue> = {};
|
||||
for (const inp of wf.input_schema ?? []) {
|
||||
if (inp.defaultValue !== undefined && inp.defaultValue !== '') next[inp.nodeId] = inp.defaultValue;
|
||||
}
|
||||
const past = (job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||||
for (const [k, v] of Object.entries(past)) {
|
||||
if (typeof v === 'string' || typeof v === 'number') next[k] = v;
|
||||
else if (Array.isArray(v) && v.every((p) => typeof p === 'string')) next[k] = v as string[];
|
||||
}
|
||||
slotRejects = {};
|
||||
workflowId = wf.id;
|
||||
lastWfId = wf.id;
|
||||
values = next;
|
||||
@@ -764,13 +917,7 @@
|
||||
<div class="panel-head">
|
||||
<h2>{t('studio.genParams')}</h2>
|
||||
{#if currentWorkflow}
|
||||
<span class="panel-hint">
|
||||
{mediaSlots.length
|
||||
? mediaSlots.map((s) => s.label).join(' · ')
|
||||
: kind === 'image'
|
||||
? t('studio.modeTextToImage')
|
||||
: t('studio.modeTextToVideo')}
|
||||
</span>
|
||||
<span class="panel-hint">{modeLabel}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if dryRun}
|
||||
@@ -839,11 +986,22 @@
|
||||
{:else if schema.some((i) => i.auto)}
|
||||
<p class="missing-note">{t('studio.wfAutoParamsNote', { n: schema.length })}</p>
|
||||
{/if}
|
||||
{#if brokenReasons.length}
|
||||
<div class="missing-note" role="alert">
|
||||
<span class="f-error">{t('studio.wfBrokenTitle')}</span>
|
||||
{#each brokenReasons as reason (reason)}
|
||||
<span class="f-error">· {reason}</span>
|
||||
{/each}
|
||||
<span class="f-error">{t('studio.wfBrokenHint')}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if mediaSlots.length}
|
||||
{@const pairKey = `${mediaSlots.find((s) => isFirstFrame(s.inp))?.inp.nodeId ?? ''}|${mediaSlots.find((s) => isLastFrame(s.inp))?.inp.nodeId ?? ''}`}
|
||||
<div class="slots">
|
||||
{#each mediaSlots as s (s.inp.nodeId)}
|
||||
{@const reject = slotRejects[s.inp.nodeId]?.[0]}
|
||||
{#if s.inp.kind === 'video' || s.inp.kind === 'audio'}
|
||||
<div class="slot-span">
|
||||
<MediaSlot
|
||||
@@ -853,7 +1011,7 @@
|
||||
uploading={uploads.isUploading(s.inp.nodeId)}
|
||||
uploadName={uploads.uploading[s.inp.nodeId]}
|
||||
error={showErrors ? errors[s.inp.nodeId] : undefined}
|
||||
onFile={(f) => slotFile(s.inp.nodeId, f)}
|
||||
onFile={(f) => slotFile(s.inp.nodeId, f, s.mediaKind)}
|
||||
onClear={() => setVal(s.inp.nodeId, '')}
|
||||
/>
|
||||
</div>
|
||||
@@ -861,29 +1019,56 @@
|
||||
<div class="slot-cell" class:span2={s.aspect === 'wide' || mediaSlots.length === 1}>
|
||||
<MediaSlot
|
||||
label={s.label}
|
||||
hint={kind === 'video' && s.fromResults ? t('studio.slotFromResults') : undefined}
|
||||
required={s.inp.required}
|
||||
hint={s.fromResults ? t('studio.slotFromResults') : s.inp.required ? t('studio.slotHintOne') : undefined}
|
||||
value={String(values[s.inp.nodeId] ?? '')}
|
||||
kind="image"
|
||||
aspect={s.aspect}
|
||||
emptyText={s.emptyText}
|
||||
emptySub={t('studio.slotEmptySub')}
|
||||
size={fileSizes[String(values[s.inp.nodeId] ?? '')]}
|
||||
uploading={uploads.isUploading(s.inp.nodeId)}
|
||||
uploadName={uploads.uploading[s.inp.nodeId]}
|
||||
error={showErrors ? errors[s.inp.nodeId] : undefined}
|
||||
error={reject?.message ?? (showErrors ? errors[s.inp.nodeId] : undefined)}
|
||||
allowFromResults={s.fromResults}
|
||||
onFile={(f) => slotFile(s.inp.nodeId, f)}
|
||||
onFromResults={() => openPicker(s.inp.nodeId)}
|
||||
onClear={() => setVal(s.inp.nodeId, '')}
|
||||
onClear={() => {
|
||||
setRejects(s.inp.nodeId, []);
|
||||
setVal(s.inp.nodeId, '');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{#if showErrors && errors[`${mediaSlots.find((s) => /first|start|首帧/.test(hay(s.inp)))?.inp.nodeId ?? ''}|${mediaSlots.find((s) => /last|end|尾帧/.test(hay(s.inp)))?.inp.nodeId ?? ''}`]}
|
||||
<span class="f-error">
|
||||
{errors[`${mediaSlots.find((s) => /first|start|首帧/.test(hay(s.inp)))?.inp.nodeId ?? ''}|${mediaSlots.find((s) => /last|end|尾帧/.test(hay(s.inp)))?.inp.nodeId ?? ''}`]}
|
||||
</span>
|
||||
{#if showErrors && errors[pairKey]}
|
||||
<span class="f-error">{errors[pairKey]}</span>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if refGroup}
|
||||
<div class="f-field">
|
||||
<RefImageGrid
|
||||
label={refGroup.label}
|
||||
paths={refPaths}
|
||||
max={refMax}
|
||||
sizes={fileSizes}
|
||||
uploadingName={uploads.uploading[refGroup.nodeId]}
|
||||
uploadingIndex={replacingIndex}
|
||||
rejects={slotRejects[refGroup.nodeId] ?? []}
|
||||
error={showErrors ? errors[refGroup.nodeId] : undefined}
|
||||
allowFromResults
|
||||
onAdd={refAdd}
|
||||
onReplace={refReplace}
|
||||
onRemove={refRemove}
|
||||
onDismissReject={(i) =>
|
||||
setRejects(refGroup.nodeId, (slotRejects[refGroup.nodeId] ?? []).filter((_, j) => j !== i))}
|
||||
onFromResults={() => openPicker(refGroup.nodeId)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if promptInp}
|
||||
<label class="f-field">
|
||||
<span class="f-label">
|
||||
@@ -1014,6 +1199,22 @@
|
||||
{@render fieldError(widthInp)}
|
||||
{@render fieldError(heightInp)}
|
||||
</div>
|
||||
{:else if resolutionInp}
|
||||
<label class="f-field">
|
||||
<span class="f-label">{t('studio.resolutionLabel')}</span>
|
||||
<input
|
||||
class="f-input mono"
|
||||
class:invalid={showErrors && errors[resolutionInp.nodeId]}
|
||||
type="number"
|
||||
min={resolutionInp.min}
|
||||
max={resolutionInp.max}
|
||||
step={resolutionInp.step ?? 32}
|
||||
value={String(values[resolutionInp.nodeId] ?? '')}
|
||||
oninput={(e) => numVal(resolutionInp.nodeId, e.currentTarget.value)}
|
||||
/>
|
||||
<span class="panel-hint">{t('studio.resolutionHint')}</span>
|
||||
{@render fieldError(resolutionInp)}
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{#if stepsInp || cfgInp || denoiseInp || batchInp || durationInp || fpsInp}
|
||||
@@ -1343,7 +1544,9 @@
|
||||
</div>
|
||||
{#if selectedFrames.length}
|
||||
<div class="frame-strip">
|
||||
<span class="strip-label">{t('studio.videoRefStrip')}</span>
|
||||
<span class="strip-label">
|
||||
{selectedRefCount ? t('studio.refStrip', { n: selectedRefCount }) : t('studio.videoRefStrip')}
|
||||
</span>
|
||||
{#each selectedFrames as fr (fr.path)}
|
||||
<div class="frame-item">
|
||||
<img src={assetUrl(fr.path)} alt={fr.label} />
|
||||
|
||||
Reference in New Issue
Block a user