HEL-665: implement approved Refract Studio across real desktop workbench
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import { tick, untrack } from 'svelte';
|
||||
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
||||
import { page } from '$app/state';
|
||||
import { goto } from '$app/navigation';
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import Modal from '$lib/components/ui/Modal.svelte';
|
||||
import AppShell from '$lib/components/shell/AppShell.svelte';
|
||||
@@ -27,12 +28,19 @@
|
||||
type FormValue,
|
||||
type FormValues,
|
||||
} from '$lib/components/generate/schema';
|
||||
import { matchesFilter, type FeedFilter } from '$lib/components/generate/takes';
|
||||
import { matchesFilter, workbenchCtxOf, type FeedFilter } from '$lib/components/generate/takes';
|
||||
import InputRequirementBadge from './InputRequirementBadge.svelte';
|
||||
import TaskModeRail from './TaskModeRail.svelte';
|
||||
import WorkflowBay from './WorkflowBay.svelte';
|
||||
import WorkflowPreview from './WorkflowPreview.svelte';
|
||||
import { apiErrorMessage, assetUrl, comfy, jobsApi, playgroundApi, projects, settings, workflows } from '$lib/api';
|
||||
import {
|
||||
apiErrorMessage,
|
||||
assetUrl,
|
||||
comfy,
|
||||
jobsApi,
|
||||
playgroundApi,
|
||||
projects,
|
||||
settings,
|
||||
workflows,
|
||||
} from '$lib/api';
|
||||
import {
|
||||
USAGE_BY_KIND,
|
||||
type Job,
|
||||
@@ -48,13 +56,9 @@
|
||||
import { toast } from '$lib/toast';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
|
||||
/**
|
||||
* 三段式生成台 (HEL-683, HEL-674 §二 / HEL-679 融合样稿): 左栏任务
|
||||
* 模式、中部工作流挑选台(挑选时展开,选定后收成摘要带)、右侧沿用
|
||||
* 参数与结果组件。`/image` 与 `/video` 共用本台,`kind` 决定任务模式,
|
||||
* `?wf=<id>` 深链指定工作流、`?mode=<usage>` 预选任务模式。项目五阶段
|
||||
* 的上下文条与返回路径保持不变(回流属 S5,不在本卡)。
|
||||
*/
|
||||
/** Refract creative studio. The large artboard and right composer share
|
||||
* existing workflow/schema/job logic. Model selection is a modal catalogue;
|
||||
* project context and explicit result attachment stay server-validated. */
|
||||
interface Props {
|
||||
kind: DeskKind;
|
||||
}
|
||||
@@ -66,11 +70,17 @@
|
||||
// ------------------------------------------------------------------
|
||||
// Data
|
||||
// ------------------------------------------------------------------
|
||||
const settingsQuery = createQuery({ queryKey: ['settings'], queryFn: settings.get });
|
||||
const settingsQuery = createQuery({
|
||||
queryKey: ['settings'],
|
||||
queryFn: settings.get,
|
||||
});
|
||||
// HEL-683: the desk browses S2's lightweight metadata (view=meta, no
|
||||
// workflow_json). Full records are fetched per id on demand — the whole
|
||||
// list (~7.6MB at 150+ rows) never loads here.
|
||||
const metaQuery = createQuery({ queryKey: ['workflows-meta'], queryFn: workflows.listMeta });
|
||||
const metaQuery = createQuery({
|
||||
queryKey: ['workflows-meta'],
|
||||
queryFn: workflows.listMeta,
|
||||
});
|
||||
const jobsQuery = createQuery({
|
||||
queryKey: ['playground-jobs'],
|
||||
queryFn: playgroundApi.jobs,
|
||||
@@ -80,7 +90,11 @@
|
||||
let ctxDismissed = $state(false);
|
||||
const ctx = $derived(ctxDismissed ? null : readDeskContext(page.url, kind));
|
||||
const projectsQuery = createQuery(
|
||||
toStore(() => ({ queryKey: ['projects'], queryFn: projects.list, enabled: !!ctx })),
|
||||
toStore(() => ({
|
||||
queryKey: ['projects'],
|
||||
queryFn: projects.list,
|
||||
enabled: !!ctx,
|
||||
})),
|
||||
);
|
||||
const ctxProjectTitle = $derived(
|
||||
($projectsQuery.data ?? []).find((p) => p.id === ctx?.projectId)?.title ??
|
||||
@@ -201,7 +215,11 @@
|
||||
// 完成:检视区若正选中该条且为视频,自动播放。
|
||||
if (selectedJobId === id) playSignal += 1;
|
||||
}
|
||||
if (ev.type === 'job.completed' && submittedIds.has(Number(ev.data.job_id)) && ev.data.dry_run) {
|
||||
if (
|
||||
ev.type === 'job.completed' &&
|
||||
submittedIds.has(Number(ev.data.job_id)) &&
|
||||
ev.data.dry_run
|
||||
) {
|
||||
toast.info(t('studio.dryRunToast'));
|
||||
}
|
||||
if (ev.type.startsWith('job.') || ev.type === 'events.resync') {
|
||||
@@ -223,10 +241,14 @@
|
||||
}
|
||||
|
||||
let bayOpen = $state(false);
|
||||
let paramsOpen = $state(false);
|
||||
let focusMode = $state(false);
|
||||
let bayActiveId = $state<number | null>(null);
|
||||
let bay = $state<WorkflowBay | null>(null);
|
||||
|
||||
const modeMetas = $derived(mode === 'all' ? deskMetas : deskMetas.filter((m) => m.usage === mode));
|
||||
const modeMetas = $derived(
|
||||
mode === 'all' ? deskMetas : deskMetas.filter((m) => m.usage === mode),
|
||||
);
|
||||
|
||||
function openBay() {
|
||||
bayActiveId = workflowId;
|
||||
@@ -295,10 +317,17 @@
|
||||
// Default workflow: this entry's usages in priority order (metadata-side;
|
||||
// error-level warnings surface through the block reason once loaded).
|
||||
$effect(() => {
|
||||
if (workflowId != null && (details.has(workflowId) || deskMetas.some((m) => m.id === workflowId))) return;
|
||||
if (
|
||||
workflowId != null &&
|
||||
(details.has(workflowId) || deskMetas.some((m) => m.id === workflowId))
|
||||
)
|
||||
return;
|
||||
const usages = USAGE_BY_KIND[kind];
|
||||
const candidates = deskMetas.filter((m) => m.usage != null && usages.includes(m.usage));
|
||||
const pick = usages.map((u) => candidates.find((m) => m.usage === u)).find(Boolean) ?? candidates[0] ?? null;
|
||||
const pick =
|
||||
usages.map((u) => candidates.find((m) => m.usage === u)).find(Boolean) ??
|
||||
candidates[0] ??
|
||||
null;
|
||||
workflowId = pick?.id ?? null;
|
||||
});
|
||||
|
||||
@@ -324,7 +353,8 @@
|
||||
const v = prevValues[s.inp.nodeId];
|
||||
if (s.mediaKind === 'image' && !s.mask && typeof v === 'string' && v) images.push(v);
|
||||
}
|
||||
for (const g of prevDs.lists) if (g.kind === 'image_list') images.push(...listPaths(prevValues, g));
|
||||
for (const g of prevDs.lists)
|
||||
if (g.kind === 'image_list') images.push(...listPaths(prevValues, g));
|
||||
for (const s of nextDs.slots) {
|
||||
if (s.mediaKind === 'image' && !s.mask && images.length) out[s.inp.nodeId] = images.shift()!;
|
||||
}
|
||||
@@ -364,7 +394,8 @@
|
||||
if (d.duration && ctx.durationSec != null) {
|
||||
const opts = d.duration.options;
|
||||
const v = String(ctx.durationSec);
|
||||
if (!opts?.length || opts.includes(v)) out[d.duration.nodeId] = d.duration.kind === 'number' ? ctx.durationSec : v;
|
||||
if (!opts?.length || opts.includes(v))
|
||||
out[d.duration.nodeId] = d.duration.kind === 'number' ? ctx.durationSec : v;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -423,26 +454,41 @@
|
||||
/** The single reason 生成 is off, in the order a user can fix things. */
|
||||
const block = $derived.by<BlockReason | null>(() => {
|
||||
if (!currentWorkflow) return { text: t('desk.needWorkflow'), tone: 'warn', target: 'desk-wf' };
|
||||
if (!endpoints.length || !endpointId) return { text: t('studio.errNoConn'), tone: 'err', target: 'desk-conn' };
|
||||
if (!endpoints.length || !endpointId)
|
||||
return { text: t('studio.errNoConn'), tone: 'err', target: 'desk-conn' };
|
||||
if (connRec?.ok === false && !dryRun) {
|
||||
return { text: t('studio.errConnDown', { time: fmtClock(connRec.at) }), tone: 'err', target: 'desk-conn' };
|
||||
return {
|
||||
text: t('studio.errConnDown', { time: fmtClock(connRec.at) }),
|
||||
tone: 'err',
|
||||
target: 'desk-conn',
|
||||
};
|
||||
}
|
||||
if (brokenReasons.length) return { text: t('studio.errWfBroken'), tone: 'err', params: true };
|
||||
const missing = missingMedia(ds, values);
|
||||
const promptMissing = !!ds.prompt && !!errors[ds.prompt.nodeId] && !String(values[ds.prompt.nodeId] ?? '').trim();
|
||||
const promptMissing =
|
||||
!!ds.prompt && !!errors[ds.prompt.nodeId] && !String(values[ds.prompt.nodeId] ?? '').trim();
|
||||
if (missing.length || promptMissing) {
|
||||
const labels = [...missing.map((m) => m.label), ...(promptMissing ? [t('studio.promptLabel')] : [])];
|
||||
const labels = [
|
||||
...missing.map((m) => m.label),
|
||||
...(promptMissing ? [t('studio.promptLabel')] : []),
|
||||
];
|
||||
return {
|
||||
text: t('desk.stillNeed', { what: labels.join('、') }),
|
||||
tone: 'warn',
|
||||
target: missing.length ? `slot-${missing[0].nodeId}` : 'desk-prompt',
|
||||
};
|
||||
}
|
||||
if (errors.firstLast) return { text: errors.firstLast, tone: 'warn', target: `slot-${ds.slots.find((s) => s.firstFrame)?.inp.nodeId}` };
|
||||
if (errors.firstLast)
|
||||
return {
|
||||
text: errors.firstLast,
|
||||
tone: 'warn',
|
||||
target: `slot-${ds.slots.find((s) => s.firstFrame)?.inp.nodeId}`,
|
||||
};
|
||||
const firstErr = Object.entries(errors).find(([, m]) => m.trim());
|
||||
if (firstErr) {
|
||||
const [id, msg] = firstErr;
|
||||
if (ds.prompt && id === ds.prompt.nodeId) return { text: msg, tone: 'err', target: 'desk-prompt' };
|
||||
if (ds.prompt && id === ds.prompt.nodeId)
|
||||
return { text: msg, tone: 'err', target: 'desk-prompt' };
|
||||
return { text: t('desk.paramError', { msg }), tone: 'err', params: true };
|
||||
}
|
||||
return null;
|
||||
@@ -562,7 +608,10 @@
|
||||
const selectedJob = $derived(
|
||||
allJobs.find((j) => j.id === selectedJobId && !pendingIds.has(j.id)) ??
|
||||
allJobs
|
||||
.filter((j) => matchesFilter(j, filter) && !pendingIds.has(j.id) && jobStatusInfo(j).tone === 'ok')
|
||||
.filter(
|
||||
(j) =>
|
||||
matchesFilter(j, filter) && !pendingIds.has(j.id) && jobStatusInfo(j).tone === 'ok',
|
||||
)
|
||||
.sort((a, b) => parseDbTs(b.created_at) - parseDbTs(a.created_at))[0] ??
|
||||
null,
|
||||
);
|
||||
@@ -595,19 +644,28 @@
|
||||
}
|
||||
|
||||
function openParams() {
|
||||
tab = 'params';
|
||||
if (wide) inspOff = false;
|
||||
else inspOpen = true;
|
||||
paramsOpen = true;
|
||||
}
|
||||
|
||||
function toggleInspector() {
|
||||
if (wide) inspOff = !inspOff;
|
||||
else inspOpen = !inspOpen;
|
||||
focusMode = !focusMode;
|
||||
window.dispatchEvent(new CustomEvent('refract-focus', { detail: focusMode }));
|
||||
}
|
||||
|
||||
function closeInspector() {
|
||||
if (wide) inspOff = true;
|
||||
else inspOpen = false;
|
||||
if (focusMode) toggleInspector();
|
||||
}
|
||||
$effect(() => () => window.dispatchEvent(new CustomEvent('refract-focus', { detail: false })));
|
||||
function selectMode(next: TaskMode) {
|
||||
mode = next;
|
||||
const choice = next === 'all' ? deskMetas[0] : deskMetas.find((m) => m.usage === next);
|
||||
if (choice) pickWorkflow(choice.id);
|
||||
else openBay();
|
||||
}
|
||||
function mediumLink(next: DeskKind) {
|
||||
const url = new URL(page.url);
|
||||
url.pathname = '/' + next;
|
||||
url.searchParams.delete('wf');
|
||||
url.searchParams.delete('mode');
|
||||
goto(url.pathname + url.search);
|
||||
}
|
||||
|
||||
const imageSlotTarget = $derived(
|
||||
@@ -646,7 +704,9 @@
|
||||
return;
|
||||
}
|
||||
const next = schemaDefaults(wf.input_schema ?? []);
|
||||
for (const [k, v] of Object.entries((job.payload?.input_values ?? {}) as Record<string, unknown>)) {
|
||||
for (const [k, v] of Object.entries(
|
||||
(job.payload?.input_values ?? {}) as Record<string, unknown>,
|
||||
)) {
|
||||
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[];
|
||||
}
|
||||
@@ -777,7 +837,9 @@
|
||||
/** Focus sits on something that owns the key (button, link, video…). */
|
||||
function onInteractive(target: EventTarget | null): boolean {
|
||||
const el = target instanceof Element ? target : null;
|
||||
return !!el?.closest('button, a, input, textarea, select, label, video, audio, [contenteditable]');
|
||||
return !!el?.closest(
|
||||
'button, a, input, textarea, select, label, video, audio, [contenteditable]',
|
||||
);
|
||||
}
|
||||
|
||||
function inLayer(target: EventTarget | null): boolean {
|
||||
@@ -855,15 +917,6 @@
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet inspectorToggle()}
|
||||
{#if !wide || inspOff}
|
||||
<button type="button" class="a-btn ghost sm" aria-keyshortcuts="]" onclick={toggleInspector}>
|
||||
<Icon name="info" size={14} />
|
||||
{t('desk.openInspector')}
|
||||
</button>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet paramsTab()}
|
||||
<ParamsPanel
|
||||
workflow={currentWorkflow}
|
||||
@@ -877,57 +930,57 @@
|
||||
/>
|
||||
{/snippet}
|
||||
|
||||
<AppShell active={kind} title={t('desk.title')}>
|
||||
<div class="studio-desk" class:picking>
|
||||
<TaskModeRail {kind} metas={deskMetas} active={mode} onSelect={(m) => (mode = m)} onPickWorkflow={pickWorkflow} />
|
||||
|
||||
<div class="bay-col">
|
||||
<WorkflowBay
|
||||
bind:this={bay}
|
||||
open={bayOpen}
|
||||
metas={modeMetas}
|
||||
{pendingCount}
|
||||
selectedId={workflowId}
|
||||
bind:activeId={bayActiveId}
|
||||
{endpoints}
|
||||
onPick={pickWorkflow}
|
||||
onClose={closeBay}
|
||||
/>
|
||||
<AppShell active={kind} title="创作台">
|
||||
<div class="refract-studio" class:focused={focusMode}>
|
||||
<div class="studio-heading">
|
||||
<div>
|
||||
<div class="eyebrow">MAKE ROOM FOR YOUR IMAGINATION</div>
|
||||
<h1>让画面,向前一步。</h1>
|
||||
</div>
|
||||
<div class="heading-actions">
|
||||
<a class="text-link" href="/canvas">云端模型与智能体 ↗</a><button
|
||||
class="a-btn secondary sm"
|
||||
onclick={toggleInspector}>{focusMode ? '退出专注' : '专注创作'} ⤢</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="main-col">
|
||||
{#if !bayOpen}
|
||||
<div class="bay-band">
|
||||
<button type="button" class="band-hit" onclick={openBay} title={t('desk.bandChange')}>
|
||||
<Icon name="playground" size={14} />
|
||||
<span class="band-mode">{mode === 'all' ? t('desk.modeAll') : usageLabel(mode)}</span>
|
||||
<span class="band-sep" aria-hidden="true">·</span>
|
||||
<span class="band-name">
|
||||
{currentWorkflow?.name ?? currentMeta?.name ?? t('desk.pickWorkflow')}
|
||||
</span>
|
||||
{#if currentMeta?.usage}<span class="a-tag">{usageLabel(currentMeta.usage)}</span>{/if}
|
||||
<InputRequirementBadge io={currentMeta?.media_io} compact />
|
||||
<span class="band-change">
|
||||
<span class="band-change-txt">{t('desk.bandChange')}</span>
|
||||
<Icon name="chevron-right" size={13} />
|
||||
</span>
|
||||
</button>
|
||||
{@render ctxBanner()}
|
||||
<div class="studio-layout">
|
||||
<section class="viewer">
|
||||
<div class="viewer-head">
|
||||
<span>创作预览</span><span
|
||||
>{selectedJob ? '第 ' + selectedJob.id + ' 次探索' : '从一个想法开始'}</span
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if picking}
|
||||
<WorkflowPreview
|
||||
meta={previewMeta}
|
||||
full={previewFull}
|
||||
currentId={workflowId}
|
||||
{endpoints}
|
||||
onUse={() => pickWorkflow(bayActiveId ?? workflowId ?? 0)}
|
||||
onToggleFav={(fav) => previewMeta && toggleFavorite(previewMeta.id, fav)}
|
||||
<Inspector
|
||||
main
|
||||
comparePath={allJobs.find(
|
||||
(j) => j.kind === 'image' && j.status === 'done' && j.id !== selectedJob?.id,
|
||||
)?.output_paths[0] ?? null}
|
||||
bind:tab
|
||||
job={selectedJob}
|
||||
wf={selectedJob ? workflowOf(selectedJob) : undefined}
|
||||
{nowMs}
|
||||
open={true}
|
||||
inactive={false}
|
||||
canSendToSlot={!!imageSlotTarget || !!imageList}
|
||||
{crossfade}
|
||||
{playSignal}
|
||||
bind:videoEl
|
||||
params={paramsTab}
|
||||
onClose={closeInspector}
|
||||
onReuse={reuse}
|
||||
onRetry={retry}
|
||||
onSendToSlot={sendToSlot}
|
||||
onDelete={requestDelete}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<div class="desk" class:insp-off={inspOff} class:off={picking}>
|
||||
<section class="center" aria-label={t('desk.title')}>
|
||||
{#if selectedJob && workbenchCtxOf(selectedJob) && selectedJob.status === 'done'}<button
|
||||
class="a-btn secondary save-project"
|
||||
disabled={attachBusyId === selectedJob.id}
|
||||
onclick={() => selectedJob && attachToProject(selectedJob)}>保存到来源项目 ↗</button
|
||||
>{/if}
|
||||
<details class="history" open>
|
||||
<summary>每一次探索 <span>查看创作记录 ↓</span></summary>
|
||||
<TakeFeed
|
||||
bind:this={feed}
|
||||
jobs={allJobs}
|
||||
@@ -941,72 +994,95 @@
|
||||
{flashIds}
|
||||
{shakeIds}
|
||||
bind:orderedIds
|
||||
banner={ctxBanner}
|
||||
{inspectorToggle}
|
||||
onSelect={(job) => selectTake(job, 'pointer')}
|
||||
onReuse={reuse}
|
||||
onRetry={retry}
|
||||
onCancel={cancel}
|
||||
onDelete={requestDelete}
|
||||
{attachBusyId}
|
||||
onAttach={attachToProject}
|
||||
/>
|
||||
{#if !$metaQuery.isLoading && !deskMetas.length}
|
||||
<div class="desk-empty" role="note">
|
||||
<Icon name="playground" size={16} />
|
||||
<span>{t('desk.noWorkflows')}</span>
|
||||
<a class="a-btn ghost sm" href="/connections">{t('studio.wfEmptyGo')}</a>
|
||||
</div>
|
||||
{/if}
|
||||
<Composer
|
||||
{ds}
|
||||
{values}
|
||||
current={currentWorkflow}
|
||||
{endpoints}
|
||||
{endpointId}
|
||||
conn={connState}
|
||||
{errors}
|
||||
{showErrors}
|
||||
{block}
|
||||
{changedCount}
|
||||
{submitting}
|
||||
{sent}
|
||||
bind:slotBusy
|
||||
bind:promptEl
|
||||
onSet={setVal}
|
||||
onOpenBay={openBay}
|
||||
onPickEndpoint={(id) => {
|
||||
endpointTouched = true;
|
||||
endpointId = id;
|
||||
}}
|
||||
onSubmit={submit}
|
||||
onReveal={reveal}
|
||||
onOpenParams={openParams}
|
||||
onFromResults={(nodeId) => (pickerFor = nodeId)}
|
||||
onSelect={(job) => selectTake(job, 'pointer')}
|
||||
onReuse={reuse}
|
||||
onRetry={retry}
|
||||
onCancel={cancel}
|
||||
onDelete={requestDelete}
|
||||
{attachBusyId}
|
||||
onAttach={attachToProject}
|
||||
/>
|
||||
</section>
|
||||
<Inspector
|
||||
bind:tab
|
||||
job={selectedJob}
|
||||
wf={selectedJob ? workflowOf(selectedJob) : undefined}
|
||||
{nowMs}
|
||||
open={inspOpen}
|
||||
inactive={wide ? inspOff : !inspOpen}
|
||||
canSendToSlot={!!imageSlotTarget || !!imageList}
|
||||
{crossfade}
|
||||
{playSignal}
|
||||
bind:videoEl
|
||||
params={paramsTab}
|
||||
onClose={closeInspector}
|
||||
onReuse={reuse}
|
||||
onRetry={retry}
|
||||
onSendToSlot={sendToSlot}
|
||||
onDelete={requestDelete}
|
||||
</details>
|
||||
</section>
|
||||
<aside class="studio-form">
|
||||
<div class="medium-switch">
|
||||
<button class:active={kind === 'image'} onclick={() => mediumLink('image')}
|
||||
>图片创作</button
|
||||
><button class:active={kind === 'video'} onclick={() => mediumLink('video')}
|
||||
>视频创作</button
|
||||
>
|
||||
</div>
|
||||
<label class="mode-label" for="creative-mode">创作方式</label><select
|
||||
id="creative-mode"
|
||||
class="a-select"
|
||||
value={mode}
|
||||
onchange={(e) => selectMode(e.currentTarget.value as TaskMode)}
|
||||
><option value="all">所有方式</option>{#each USAGE_BY_KIND[kind] as usage}<option
|
||||
value={usage}>{usageLabel(usage)}</option
|
||||
>{/each}</select
|
||||
>
|
||||
<button class="model-selector" onclick={openBay}
|
||||
><span class="model-symbol">✳</span><span
|
||||
><small>本次创作的模型与工作流</small><strong
|
||||
>{currentWorkflow?.name ?? currentMeta?.name ?? '选择创作工具'}</strong
|
||||
></span
|
||||
><span>↗</span></button
|
||||
>
|
||||
{#if currentMeta?.usage}<div class="requirement">
|
||||
<span>{usageLabel(currentMeta.usage)}</span><InputRequirementBadge
|
||||
io={currentMeta.media_io}
|
||||
compact
|
||||
/>
|
||||
</div>{/if}
|
||||
{#if !$metaQuery.isLoading && !deskMetas.length}<p class="no-workflows">
|
||||
还没有可运行的工作流。<a href="/workflows">导入并完成映射 ↗</a>
|
||||
</p>{/if}
|
||||
<Composer
|
||||
{ds}
|
||||
{values}
|
||||
current={currentWorkflow}
|
||||
{endpoints}
|
||||
{endpointId}
|
||||
conn={connState}
|
||||
{errors}
|
||||
{showErrors}
|
||||
{block}
|
||||
{changedCount}
|
||||
{submitting}
|
||||
{sent}
|
||||
bind:slotBusy
|
||||
bind:promptEl
|
||||
onSet={setVal}
|
||||
onOpenBay={openBay}
|
||||
onPickEndpoint={(id) => {
|
||||
endpointTouched = true;
|
||||
endpointId = id;
|
||||
}}
|
||||
onSubmit={submit}
|
||||
onReveal={reveal}
|
||||
onOpenParams={openParams}
|
||||
onFromResults={(nodeId) => (pickerFor = nodeId)}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</AppShell>
|
||||
<Modal bind:open={bayOpen} size="xl" title="找到这次创作的工具。">
|
||||
<div class="workflow-modal">
|
||||
<WorkflowBay
|
||||
bind:this={bay}
|
||||
open={bayOpen}
|
||||
metas={modeMetas}
|
||||
{pendingCount}
|
||||
selectedId={workflowId}
|
||||
bind:activeId={bayActiveId}
|
||||
{endpoints}
|
||||
onPick={pickWorkflow}
|
||||
onClose={closeBay}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
<Modal bind:open={paramsOpen} size="lg" title="调整这次创作的参数">{@render paramsTab()}</Modal>
|
||||
|
||||
<Modal open={pickerFor != null} title={t('studio.pickerTitle')} onclose={() => (pickerFor = null)}>
|
||||
{#if imageResults.length}
|
||||
@@ -1023,195 +1099,222 @@
|
||||
</Modal>
|
||||
|
||||
<style>
|
||||
.studio-desk {
|
||||
display: grid;
|
||||
grid-template-columns: 204px 0px minmax(0, 1fr);
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
transition: grid-template-columns var(--d-drawer) var(--ease-drawer);
|
||||
.refract-studio {
|
||||
padding: 28px 36px 56px;
|
||||
max-width: 1560px;
|
||||
margin: auto;
|
||||
}
|
||||
.studio-desk.picking {
|
||||
grid-template-columns: 204px clamp(340px, 28vw, 440px) minmax(0, 1fr);
|
||||
}
|
||||
:global(:root[data-reduce='1']) .studio-desk {
|
||||
transition: none;
|
||||
}
|
||||
.bay-col {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.main-col {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
.desk {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 420px;
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
transition: grid-template-columns var(--d-drawer) var(--ease-drawer);
|
||||
}
|
||||
.desk.insp-off {
|
||||
grid-template-columns: minmax(0, 1fr) 0px;
|
||||
}
|
||||
.desk.off {
|
||||
display: none;
|
||||
}
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
.desk-empty {
|
||||
.studio-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-3);
|
||||
margin: 0 var(--sp-7) var(--sp-3);
|
||||
padding: var(--sp-4) var(--sp-5);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--warn-soft);
|
||||
color: var(--warn);
|
||||
font-size: var(--fs-aux);
|
||||
justify-content: space-between;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
/* 摘要带(选定后):整条可点,展开挑选台。 */
|
||||
.bay-band {
|
||||
flex-shrink: 0;
|
||||
padding: var(--sp-2) var(--sp-7);
|
||||
.eyebrow {
|
||||
font-size: 9px;
|
||||
letter-spacing: 1.3px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.band-hit {
|
||||
h1 {
|
||||
margin: 8px 0 0;
|
||||
font-size: 29px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.8px;
|
||||
}
|
||||
.heading-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
gap: 16px;
|
||||
}
|
||||
.text-link {
|
||||
font-size: 11px;
|
||||
text-decoration: none;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.studio-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(450px, 1fr) 304px;
|
||||
gap: 24px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.viewer {
|
||||
min-width: 0;
|
||||
padding: var(--sp-2) var(--sp-4);
|
||||
align-self: start;
|
||||
}
|
||||
.viewer-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 11px;
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.viewer-head span:first-child {
|
||||
color: var(--text);
|
||||
font-weight: 550;
|
||||
}
|
||||
.studio-form {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--bg-2);
|
||||
color: var(--text-2);
|
||||
font: inherit;
|
||||
font-size: var(--fs-aux);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color var(--d-state) ease,
|
||||
color var(--d-state) ease;
|
||||
border-radius: 14px;
|
||||
padding: 20px;
|
||||
min-width: 0;
|
||||
align-self: start;
|
||||
}
|
||||
.band-hit:hover {
|
||||
border-color: var(--line-2);
|
||||
.medium-switch {
|
||||
display: flex;
|
||||
padding: 4px;
|
||||
background: var(--bg);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 21px;
|
||||
}
|
||||
.medium-switch button {
|
||||
flex: 1;
|
||||
height: 32px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
cursor: pointer;
|
||||
}
|
||||
.medium-switch button.active {
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
box-shadow: 0 2px 4px #292a2d0a;
|
||||
}
|
||||
.mode-label {
|
||||
display: block;
|
||||
font-size: 10px;
|
||||
color: var(--text-2);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.studio-form > .a-select {
|
||||
width: 100%;
|
||||
height: 37px;
|
||||
}
|
||||
.model-selector {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 14px 0;
|
||||
margin: 8px 0 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
color: var(--text);
|
||||
}
|
||||
.band-hit:focus-visible {
|
||||
outline: none;
|
||||
border-color: var(--accent-line);
|
||||
}
|
||||
.band-mode {
|
||||
.model-symbol {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 9px;
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
font-size: 23px;
|
||||
flex-shrink: 0;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.band-sep {
|
||||
color: var(--text-3);
|
||||
}
|
||||
.band-name {
|
||||
.model-selector > span:nth-child(2) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.model-selector small {
|
||||
font-size: 9px;
|
||||
color: var(--text-3);
|
||||
display: block;
|
||||
}
|
||||
.model-selector strong {
|
||||
font-size: 11px;
|
||||
display: block;
|
||||
line-height: 1.7;
|
||||
font-weight: 550;
|
||||
margin-top: 4px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
.band-change {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
.requirement {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 12px;
|
||||
font-size: 9px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.band-change-txt {
|
||||
font-size: var(--fs-mini);
|
||||
.workflow-modal {
|
||||
height: min(610px, 75vh);
|
||||
}
|
||||
.history {
|
||||
margin-top: 22px;
|
||||
}
|
||||
.history summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
font-weight: 550;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
.history summary span {
|
||||
font-size: 10px;
|
||||
font-weight: 400;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.history :global(.feed) {
|
||||
max-height: 320px;
|
||||
padding: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
.history :global(.filters) {
|
||||
padding: 12px 0;
|
||||
}
|
||||
.save-project {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.no-workflows {
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.picker-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
||||
gap: var(--sp-4);
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
.picker-item {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--bg-3);
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
background: var(--surface);
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: border-color var(--d-state) ease;
|
||||
}
|
||||
.picker-item img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
height: 150px;
|
||||
object-fit: cover;
|
||||
}
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.picker-item:hover {
|
||||
border-color: var(--line-2);
|
||||
}
|
||||
}
|
||||
.picker-empty {
|
||||
margin: 0;
|
||||
color: var(--text-3);
|
||||
font-size: var(--fs-aux);
|
||||
text-align: center;
|
||||
padding: 32px;
|
||||
}
|
||||
/* 中屏:挑选台为全屏浮层(组件内处理),列宽归零。 */
|
||||
@media (max-width: 1179px) {
|
||||
.studio-desk,
|
||||
.studio-desk.picking {
|
||||
grid-template-columns: 204px 0px minmax(0, 1fr);
|
||||
@media (max-width: 1250px) {
|
||||
.refract-studio {
|
||||
padding: 25px;
|
||||
}
|
||||
.desk,
|
||||
.desk.insp-off {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
.studio-layout {
|
||||
grid-template-columns: minmax(400px, 1fr) 285px;
|
||||
gap: 16px;
|
||||
}
|
||||
.desk-empty {
|
||||
margin: 0 var(--sp-6) var(--sp-3);
|
||||
}
|
||||
.bay-band {
|
||||
padding: var(--sp-2) var(--sp-6);
|
||||
}
|
||||
}
|
||||
/* 窄屏:任务模式变横条,摘要带仍可用。 */
|
||||
@media (max-width: 760px) {
|
||||
.studio-desk,
|
||||
.studio-desk.picking {
|
||||
grid-template-columns: minmax(0, 1fr) 0px;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
}
|
||||
.bay-col {
|
||||
grid-column: 2;
|
||||
grid-row: 1 / span 2;
|
||||
}
|
||||
.main-col {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
}
|
||||
.desk-empty {
|
||||
margin: 0 var(--sp-5) var(--sp-2);
|
||||
}
|
||||
.bay-band {
|
||||
padding: var(--sp-1) var(--sp-4) var(--sp-2);
|
||||
}
|
||||
.band-change-txt {
|
||||
display: none;
|
||||
.studio-form {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
<script lang="ts">
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import { tick } from 'svelte';
|
||||
import { createQuery, useQueryClient } from '@tanstack/svelte-query';
|
||||
import { workflows, settings, apiErrorMessage } from '$lib/api';
|
||||
import type { WorkflowMeta } from '$lib/comfy/types';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
import { usageLabel } from '$lib/components/generate/schema';
|
||||
import LibraryFilters from './LibraryFilters.svelte';
|
||||
import LibraryRow from './LibraryRow.svelte';
|
||||
|
||||
/**
|
||||
* 工作流挑选台 (HEL-683, HEL-674 §二):中部可搜索筛选、按模型家族
|
||||
* 分组的挑选列。数据来自 S2 轻量元数据(view=meta,不含完整 JSON);
|
||||
* 云端来源只做诚实占位(未接入,不可点击使用)。键盘:↑↓/J/K 游走、
|
||||
* Enter 使用、Esc 关闭。长列表增量渲染 + content-visibility。
|
||||
*/
|
||||
import InputRequirementBadge from './InputRequirementBadge.svelte';
|
||||
import { toast } from '$lib/toast';
|
||||
interface Props {
|
||||
open: boolean;
|
||||
metas: WorkflowMeta[];
|
||||
@@ -22,467 +15,498 @@
|
||||
endpoints: Array<{ id: string; name: string }>;
|
||||
onPick: (id: number) => void;
|
||||
onClose: () => void;
|
||||
catalogue?: boolean;
|
||||
}
|
||||
|
||||
let { open, metas, pendingCount, selectedId, activeId = $bindable(null), endpoints, onPick, onClose }: Props =
|
||||
$props();
|
||||
|
||||
let search = $state('');
|
||||
let source = $state<'local' | 'cloud'>('local');
|
||||
let favOnly = $state(false);
|
||||
let visibleCount = $state(48);
|
||||
let searchEl = $state<HTMLInputElement | null>(null);
|
||||
let listEl = $state<HTMLElement | null>(null);
|
||||
|
||||
const CATEGORY_LABELS: Record<string, string> = {
|
||||
basic: 'wfCat.basic',
|
||||
audio_tts: 'wfCat.audioTts',
|
||||
music: 'wfCat.music',
|
||||
image: 'wfCat.image',
|
||||
video: 'wfCat.video',
|
||||
digital_human: 'wfCat.digitalHuman',
|
||||
motion_transfer: 'wfCat.motionTransfer',
|
||||
let {
|
||||
open,
|
||||
metas,
|
||||
pendingCount,
|
||||
selectedId,
|
||||
activeId = $bindable(null),
|
||||
endpoints,
|
||||
onPick,
|
||||
onClose,
|
||||
catalogue = false,
|
||||
}: Props = $props();
|
||||
const client = useQueryClient();
|
||||
const modelsQuery = createQuery({
|
||||
queryKey: ['settings'],
|
||||
queryFn: settings.get,
|
||||
});
|
||||
let search = $state(''),
|
||||
category = $state('all'),
|
||||
family = $state('all'),
|
||||
source = $state('local'),
|
||||
favOnly = $state(false),
|
||||
recentOnly = $state(false),
|
||||
visibleCount = $state(48);
|
||||
let searchEl: HTMLInputElement;
|
||||
let listEl: HTMLDivElement;
|
||||
const labels: Record<string, string> = {
|
||||
basic: '基础工具',
|
||||
audio_tts: '语音',
|
||||
music: '音乐',
|
||||
image: '图片',
|
||||
video: '视频',
|
||||
digital_human: '数字人',
|
||||
motion_transfer: '动作',
|
||||
};
|
||||
function categoryLabel(key: string | null | undefined): string {
|
||||
if (!key) return '';
|
||||
const k = CATEGORY_LABELS[key];
|
||||
return k ? t(k) : key;
|
||||
}
|
||||
|
||||
const filtered = $derived.by(() => {
|
||||
const q = search.trim().toLowerCase();
|
||||
return metas.filter((m) => {
|
||||
if (favOnly && !m.favorite) return false;
|
||||
if (!q) return true;
|
||||
const hay = [
|
||||
m.name,
|
||||
m.description ?? '',
|
||||
(m.tags ?? []).join(' '),
|
||||
m.model_family ?? '',
|
||||
m.usage ? usageLabel(m.usage) : '',
|
||||
categoryLabel(m.category),
|
||||
]
|
||||
.join(' ')
|
||||
.toLowerCase();
|
||||
return hay.includes(q);
|
||||
});
|
||||
});
|
||||
|
||||
interface Group {
|
||||
key: string;
|
||||
label: string;
|
||||
rows: WorkflowMeta[];
|
||||
}
|
||||
const groups = $derived.by(() => {
|
||||
const byFamily = new Map<string, WorkflowMeta[]>();
|
||||
for (const m of filtered) {
|
||||
const key = m.model_family ?? '';
|
||||
const list = byFamily.get(key) ?? [];
|
||||
list.push(m);
|
||||
byFamily.set(key, list);
|
||||
}
|
||||
const out: Group[] = [];
|
||||
for (const [key, rows] of byFamily) {
|
||||
rows.sort((a, b) => {
|
||||
if (a.favorite !== b.favorite) return a.favorite ? -1 : 1;
|
||||
const la = a.last_used_at ?? '';
|
||||
const lb = b.last_used_at ?? '';
|
||||
if (la !== lb) return lb.localeCompare(la);
|
||||
return a.name.localeCompare(b.name, 'zh');
|
||||
});
|
||||
out.push({ key, label: key || t('desk.bayNoFamily'), rows });
|
||||
}
|
||||
out.sort((a, b) =>
|
||||
a.key === '' ? 1 : b.key === '' ? -1 : a.label.localeCompare(b.label, 'zh'),
|
||||
);
|
||||
return out;
|
||||
});
|
||||
|
||||
const flat = $derived(groups.flatMap((g) => g.rows));
|
||||
|
||||
/** Flattened rows cut at the incremental window, per group. */
|
||||
const windowed = $derived.by(() => {
|
||||
let left = visibleCount;
|
||||
return groups.map((g) => {
|
||||
const take = Math.max(0, Math.min(g.rows.length, left));
|
||||
left -= take;
|
||||
return { ...g, visible: g.rows.slice(0, take) };
|
||||
});
|
||||
});
|
||||
|
||||
// Any filter change restarts the incremental window.
|
||||
const categories = $derived([
|
||||
...new Set(metas.map((m) => m.category).filter((k): k is string => !!k)),
|
||||
]);
|
||||
const families = $derived(
|
||||
[...new Set(metas.map((m) => m.model_family).filter((k): k is string => !!k))].sort(),
|
||||
);
|
||||
const filtered = $derived(
|
||||
metas
|
||||
.filter(
|
||||
(m) =>
|
||||
(category === 'all' || m.category === category) &&
|
||||
(family === 'all' || m.model_family === family) &&
|
||||
(!favOnly || m.favorite) &&
|
||||
(!recentOnly || m.last_used_at) &&
|
||||
(!search.trim() ||
|
||||
[
|
||||
m.name,
|
||||
m.description,
|
||||
...(m.tags ?? []),
|
||||
m.model_family,
|
||||
m.usage ? usageLabel(m.usage) : '',
|
||||
]
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase().trim())),
|
||||
)
|
||||
.sort((a, b) =>
|
||||
recentOnly
|
||||
? (b.last_used_at ?? '').localeCompare(a.last_used_at ?? '')
|
||||
: Number(b.favorite) - Number(a.favorite) || a.name.localeCompare(b.name, 'zh'),
|
||||
),
|
||||
);
|
||||
const visible = $derived(filtered.slice(0, visibleCount));
|
||||
const cloudModels = $derived(
|
||||
($modelsQuery.data?.llm_profiles ?? []).filter(
|
||||
(p) => !search || [p.name, p.model].join(' ').toLowerCase().includes(search.toLowerCase()),
|
||||
),
|
||||
);
|
||||
$effect(() => {
|
||||
void search;
|
||||
void category;
|
||||
void family;
|
||||
void favOnly;
|
||||
void recentOnly;
|
||||
visibleCount = 48;
|
||||
listEl?.scrollTo({ top: 0 });
|
||||
});
|
||||
|
||||
// Keep the active row real: follow the selection, clamp on filter changes.
|
||||
$effect(() => {
|
||||
void flat;
|
||||
if (activeId != null && flat.some((m) => m.id === activeId)) return;
|
||||
activeId = flat.find((m) => m.id === selectedId)?.id ?? flat[0]?.id ?? null;
|
||||
});
|
||||
|
||||
// Opening the bay: the selected workflow's row must be inside the
|
||||
// incremental window and in view — otherwise the highlight is invisible.
|
||||
$effect(() => {
|
||||
if (!open) return;
|
||||
const target = activeId ?? selectedId;
|
||||
const idx = flat.findIndex((m) => m.id === target);
|
||||
if (idx < 0) return;
|
||||
const idx = filtered.findIndex((m) => m.id === selectedId);
|
||||
if (idx >= visibleCount) visibleCount = idx + 48;
|
||||
const id = setTimeout(() => {
|
||||
document
|
||||
.querySelector<HTMLElement>(`[data-wf-row="${target}"]`)
|
||||
?.scrollIntoView({ block: 'center' });
|
||||
}, 0);
|
||||
return () => clearTimeout(id);
|
||||
void tick().then(() => searchEl?.focus());
|
||||
});
|
||||
|
||||
const activeMeta = $derived(metas.find((m) => m.id === activeId) ?? null);
|
||||
const resultHint = $derived(
|
||||
source === 'cloud' ? '' : t('desk.bayCount', { n: filtered.length, total: metas.length }),
|
||||
);
|
||||
|
||||
// Autofocus the search whenever the bay opens.
|
||||
$effect(() => {
|
||||
if (!open) return;
|
||||
const id = setTimeout(() => searchEl?.focus(), 0);
|
||||
return () => clearTimeout(id);
|
||||
if (!filtered.some((m) => m.id === activeId)) activeId = filtered[0]?.id ?? null;
|
||||
});
|
||||
|
||||
function moveActive(delta: number) {
|
||||
if (!flat.length) return;
|
||||
let i = flat.findIndex((m) => m.id === activeId);
|
||||
i = i < 0 ? (delta > 0 ? 0 : flat.length - 1) : i + delta;
|
||||
i = Math.max(0, Math.min(flat.length - 1, i));
|
||||
const next = flat[i];
|
||||
activeId = next.id;
|
||||
// Keyboard roving may step past the incremental window — extend it so
|
||||
// the row exists, then reveal it.
|
||||
if (i >= visibleCount) visibleCount = i + 24;
|
||||
void tick().then(() => {
|
||||
document
|
||||
.querySelector<HTMLElement>(`[data-wf-row="${next.id}"]`)
|
||||
?.scrollIntoView({ block: 'nearest' });
|
||||
});
|
||||
}
|
||||
|
||||
function pickActive() {
|
||||
if (activeMeta) onPick(activeMeta.id);
|
||||
}
|
||||
|
||||
export function focusSearch() {
|
||||
searchEl?.focus();
|
||||
}
|
||||
|
||||
function onKeydown(e: KeyboardEvent) {
|
||||
if (e.defaultPrevented) return;
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
return;
|
||||
}
|
||||
const inSearch = e.target === searchEl;
|
||||
if (e.key === 'ArrowDown' || (!inSearch && e.key === 'j')) {
|
||||
e.preventDefault();
|
||||
moveActive(1);
|
||||
} else if (e.key === 'ArrowUp' || (!inSearch && e.key === 'k')) {
|
||||
e.preventDefault();
|
||||
moveActive(-1);
|
||||
} else if (e.key === 'Enter' && !e.ctrlKey && !e.metaKey) {
|
||||
e.preventDefault();
|
||||
pickActive();
|
||||
async function favorite(m: WorkflowMeta) {
|
||||
try {
|
||||
await workflows.update(m.id, { favorite: !m.favorite });
|
||||
await client.invalidateQueries({ queryKey: ['workflows-meta'] });
|
||||
} catch (e) {
|
||||
toast.error(apiErrorMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
function onScroll() {
|
||||
const el = listEl;
|
||||
if (!el) return;
|
||||
if (el.scrollTop + el.clientHeight >= el.scrollHeight - 240) {
|
||||
if (visibleCount < flat.length) visibleCount += 48;
|
||||
function pick(m: WorkflowMeta) {
|
||||
if (m.is_enabled && !m.needs_mapping && m.usage) onPick(m.id);
|
||||
}
|
||||
function move(delta: number) {
|
||||
const i = Math.max(
|
||||
0,
|
||||
Math.min(filtered.length - 1, filtered.findIndex((m) => m.id === activeId) + delta),
|
||||
);
|
||||
activeId = filtered[i]?.id ?? null;
|
||||
if (i >= visibleCount) visibleCount = i + 24;
|
||||
void tick().then(() =>
|
||||
listEl?.querySelector(`[data-wf-row="${activeId}"]`)?.scrollIntoView({ block: 'nearest' }),
|
||||
);
|
||||
}
|
||||
function key(e: KeyboardEvent) {
|
||||
if (e.defaultPrevented) return;
|
||||
if (e.key === 'Escape' && !catalogue) {
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
} else if (e.key === 'ArrowDown') {
|
||||
e.preventDefault();
|
||||
move(1);
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
e.preventDefault();
|
||||
move(-1);
|
||||
} else if (e.key === 'Enter' && e.target === searchEl) {
|
||||
e.preventDefault();
|
||||
const m = filtered.find((m) => m.id === activeId);
|
||||
if (m) pick(m);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if open}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="bay-backdrop" onclick={onClose} aria-hidden="true"></div>
|
||||
{/if}
|
||||
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
||||
<section
|
||||
class="bay"
|
||||
class:open
|
||||
aria-label={t('desk.pickWorkflow')}
|
||||
inert={!open}
|
||||
onkeydown={onKeydown}
|
||||
>
|
||||
<header class="bay-head">
|
||||
<h2 class="bay-title">
|
||||
<Icon name="playground" size={15} />
|
||||
<span>{t('desk.pickWorkflow')}</span>
|
||||
</h2>
|
||||
<button type="button" class="a-btn ghost sm close" onclick={onClose} title={t('desk.keyClose')}>
|
||||
<Icon name="close" size={14} />
|
||||
<span class="lbl">{t('desk.keyClose')}</span>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="bay-filters">
|
||||
<LibraryFilters
|
||||
bind:searchEl
|
||||
{search}
|
||||
{source}
|
||||
{favOnly}
|
||||
{resultHint}
|
||||
onSetSearch={(v) => (search = v)}
|
||||
onSetSource={(s) => (source = s)}
|
||||
onToggleFav={() => (favOnly = !favOnly)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if source === 'cloud'}
|
||||
<div class="cloud-note" role="note">
|
||||
<Icon name="alert" size={16} />
|
||||
<p class="cloud-title">{t('desk.bayCloudTitle')}</p>
|
||||
<p class="cloud-body">{t('desk.bayCloudBody')}</p>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="catalogue" inert={!open} onkeydown={key}>
|
||||
<aside class="categories">
|
||||
<p>按创作任务寻找</p>
|
||||
<button
|
||||
class:active={category === 'all' && !favOnly && !recentOnly}
|
||||
onclick={() => {
|
||||
category = 'all';
|
||||
favOnly = false;
|
||||
recentOnly = false;
|
||||
}}><span>全部工具</span><small>{metas.length}</small></button
|
||||
>
|
||||
{#each categories as cat}<button
|
||||
class:active={category === cat}
|
||||
onclick={() => {
|
||||
category = cat;
|
||||
favOnly = false;
|
||||
recentOnly = false;
|
||||
}}
|
||||
><span>{labels[cat] ?? cat}</span><small
|
||||
>{metas.filter((m) => m.category === cat).length}</small
|
||||
></button
|
||||
>{/each}
|
||||
<div class="divider"></div>
|
||||
<button
|
||||
class:active={favOnly}
|
||||
onclick={() => {
|
||||
favOnly = !favOnly;
|
||||
recentOnly = false;
|
||||
}}><span>☆ 我的收藏</span><small>{metas.filter((m) => m.favorite).length}</small></button
|
||||
><button
|
||||
class:active={recentOnly}
|
||||
onclick={() => {
|
||||
recentOnly = !recentOnly;
|
||||
favOnly = false;
|
||||
}}><span>◷ 最近使用</span></button
|
||||
>
|
||||
</aside>
|
||||
<section class="catalogue-main">
|
||||
<label class="search"
|
||||
><span>⌕</span><input
|
||||
type="search"
|
||||
bind:this={searchEl}
|
||||
bind:value={search}
|
||||
placeholder="搜索工作流、模型或用途…"
|
||||
aria-label="搜索工作流"
|
||||
/></label
|
||||
>
|
||||
<div class="filters">
|
||||
<button class:active={source === 'local'} onclick={() => (source = 'local')}
|
||||
>本地 ComfyUI</button
|
||||
><button class:active={source === 'cloud'} onclick={() => (source = 'cloud')}
|
||||
>云端与智能体</button
|
||||
>{#if source === 'local'}<select aria-label="筛选模型家族" bind:value={family}
|
||||
><option value="all">全部模型</option>{#each families as f}<option value={f}>{f}</option
|
||||
>{/each}</select
|
||||
>{/if}<span>{source === 'local' ? filtered.length : cloudModels.length} 个结果</span>
|
||||
</div>
|
||||
{:else if !metas.length}
|
||||
<div class="bay-empty">
|
||||
<p>{t('desk.noWorkflows')}</p>
|
||||
<a class="a-btn ghost sm" href="/connections">{t('studio.wfEmptyGo')}</a>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="bay-list" bind:this={listEl} role="listbox" aria-label={t('desk.pickWorkflow')} onscroll={onScroll}>
|
||||
{#each windowed as g (g.key)}
|
||||
{#if g.visible.length}
|
||||
<div class="group-label" aria-hidden="true">{g.label} · {g.rows.length}</div>
|
||||
{#each g.visible as m (m.id)}
|
||||
<div data-wf-row={m.id}>
|
||||
<LibraryRow
|
||||
meta={m}
|
||||
current={m.id === selectedId}
|
||||
active={m.id === activeId}
|
||||
{endpoints}
|
||||
onPick={() => onPick(m.id)}
|
||||
onActive={() => (activeId = m.id)}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
<div class="results" bind:this={listEl}>
|
||||
{#if source === 'cloud'}
|
||||
<div class="cloud-context">
|
||||
<h3>让专业搭档加入创作。</h3>
|
||||
<p>使用已配置模型,在智能体或画布中创作。自定义多媒体接口与技能可在设置中管理。</p>
|
||||
<a href="/canvas" class="a-btn primary">打开创作画布 ↗</a>
|
||||
</div>
|
||||
{#each cloudModels as profile}<article class="workflow-card">
|
||||
<div class="family">{profile.model}<span>已配置模型</span></div>
|
||||
<h3>{profile.name}</h3>
|
||||
<a href="/agents" class="tool-link">交给智能体创作 ↗</a>
|
||||
</article>{:else}<p class="empty">
|
||||
还没有匹配的模型。<a href="/models">配置模型 ↗</a>
|
||||
</p>{/each}
|
||||
{:else}
|
||||
<p class="bay-none">{t('desk.wfNoMatch')}</p>
|
||||
{/each}
|
||||
{#if visibleCount < flat.length}
|
||||
<button type="button" class="more a-btn ghost sm" onclick={() => (visibleCount += 48)}>
|
||||
{t('desk.bayMore', { n: Math.min(48, flat.length - visibleCount) })}
|
||||
</button>
|
||||
{#each visible as m (m.id)}<article
|
||||
class="workflow-card"
|
||||
class:selected={m.id === selectedId}
|
||||
class:roving={m.id === activeId}
|
||||
data-wf-row={m.id}
|
||||
>
|
||||
<button
|
||||
class="workflow-choice"
|
||||
onclick={() => pick(m)}
|
||||
onfocus={() => (activeId = m.id)}
|
||||
disabled={!m.is_enabled || m.needs_mapping || !m.usage}
|
||||
aria-label="使用 {m.name}"
|
||||
aria-current={m.id === selectedId ? 'true' : undefined}
|
||||
>
|
||||
<div class="family">
|
||||
{m.model_family ?? 'COMFYUI'}<span>本地</span>
|
||||
</div>
|
||||
<h3 title={m.name}>{m.name}</h3>
|
||||
<div class="card-meta">
|
||||
<span>{m.usage ? usageLabel(m.usage) : '待映射'}</span><InputRequirementBadge
|
||||
io={m.media_io}
|
||||
compact
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="favorite"
|
||||
class:saved={m.favorite}
|
||||
aria-label="{m.favorite ? '取消收藏' : '收藏'} {m.name}"
|
||||
aria-pressed={m.favorite}
|
||||
onclick={() => favorite(m)}>{m.favorite ? '★' : '☆'}</button
|
||||
>
|
||||
{#if m.needs_mapping || !m.is_enabled || !m.usage}<a
|
||||
href="/workflows?manage=1"
|
||||
class="tool-link">{m.needs_mapping ? '完成映射' : '管理工作流'} ↗</a
|
||||
>{/if}
|
||||
</article>{:else}<p class="empty">没有找到匹配的工作流,试试更短的关键词。</p>{/each}
|
||||
{#if visibleCount < filtered.length}<button
|
||||
class="more a-btn secondary"
|
||||
onclick={() => (visibleCount += 48)}
|
||||
>再看 {Math.min(48, filtered.length - visibleCount)} 个工具</button
|
||||
>{/if}
|
||||
{/if}
|
||||
</div>
|
||||
<footer class="bay-foot">
|
||||
{#if pendingCount > 0}
|
||||
<a class="pending-link" href="/connections">
|
||||
{t('desk.bayPending', { n: pendingCount })}
|
||||
<Icon name="chevron-right" size={12} />
|
||||
</a>
|
||||
{/if}
|
||||
{#if activeMeta}
|
||||
<span class="active-name" title={activeMeta.name}>{activeMeta.name}</span>
|
||||
{/if}
|
||||
<span class="keys">
|
||||
<span class="a-kbd">↑↓</span>{t('desk.keySelect')}
|
||||
<span class="a-kbd">Enter</span>{t('desk.keyUse')}
|
||||
<span class="a-kbd">Esc</span>{t('desk.keyClose')}
|
||||
</span>
|
||||
</footer>
|
||||
{/if}
|
||||
</section>
|
||||
{#if pendingCount > 0}<p class="pending">
|
||||
另有 {pendingCount} 个工作流待映射。<a href="/workflows?manage=1">去整理 ↗</a>
|
||||
</p>{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.bay {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.catalogue {
|
||||
display: grid;
|
||||
grid-template-columns: 178px minmax(0, 1fr);
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
box-sizing: border-box;
|
||||
padding: var(--sp-5) var(--sp-4) var(--sp-3);
|
||||
overflow: hidden;
|
||||
}
|
||||
.bay-head {
|
||||
.categories {
|
||||
padding: 16px 15px 20px 0;
|
||||
border-right: 1px solid var(--line);
|
||||
overflow: auto;
|
||||
}
|
||||
.categories p {
|
||||
font-size: 9px;
|
||||
letter-spacing: 1px;
|
||||
color: var(--text-3);
|
||||
margin: 0 9px 15px;
|
||||
}
|
||||
.categories button {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: 0 var(--sp-2) var(--sp-4);
|
||||
width: 100%;
|
||||
border: 0;
|
||||
background: none;
|
||||
border-radius: 7px;
|
||||
text-align: left;
|
||||
font-size: 11px;
|
||||
padding: 11px 10px;
|
||||
color: var(--text-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
.bay-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
font-size: var(--fs-title);
|
||||
font-weight: 600;
|
||||
.categories button.active {
|
||||
background: #e8eafe;
|
||||
color: var(--accent);
|
||||
}
|
||||
.bay-title :global(svg) {
|
||||
.categories small {
|
||||
font-size: 9px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.close {
|
||||
margin-left: auto;
|
||||
.divider {
|
||||
border-top: 1px solid var(--line);
|
||||
margin: 20px 8px 12px;
|
||||
}
|
||||
.close .lbl {
|
||||
display: none;
|
||||
}
|
||||
.bay-filters {
|
||||
padding: 0 var(--sp-1) var(--sp-3);
|
||||
}
|
||||
.bay-list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
.catalogue-main {
|
||||
padding: 16px 0 0 22px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: var(--sp-1);
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.group-label {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: var(--sp-3) var(--sp-3) var(--sp-1);
|
||||
background: linear-gradient(var(--bg-2) 82%, transparent);
|
||||
.search {
|
||||
display: flex;
|
||||
gap: 9px;
|
||||
align-items: center;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--line);
|
||||
padding: 9px 13px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.search input {
|
||||
border: 0;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
}
|
||||
.search:focus-within {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.filters {
|
||||
display: flex;
|
||||
gap: 7px;
|
||||
align-items: center;
|
||||
margin: 16px 0 21px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.filters button,
|
||||
.filters select {
|
||||
font-size: 10px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 20px;
|
||||
background: var(--surface);
|
||||
color: var(--text-3);
|
||||
cursor: pointer;
|
||||
}
|
||||
.filters button.active {
|
||||
color: var(--surface);
|
||||
background: var(--text);
|
||||
border-color: var(--text);
|
||||
}
|
||||
.filters span {
|
||||
font-size: 9px;
|
||||
color: var(--text-3);
|
||||
margin-left: auto;
|
||||
}
|
||||
.filters select {
|
||||
max-width: 140px;
|
||||
}
|
||||
.results {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 11px;
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
align-content: start;
|
||||
padding: 2px 5px 15px 2px;
|
||||
}
|
||||
.workflow-card {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 11px;
|
||||
padding: 14px;
|
||||
position: relative;
|
||||
background: var(--surface);
|
||||
min-width: 0;
|
||||
content-visibility: auto;
|
||||
contain-intrinsic-size: auto 132px;
|
||||
}
|
||||
.workflow-card.selected {
|
||||
border-color: var(--accent);
|
||||
background: #f1f3ff;
|
||||
}
|
||||
.workflow-choice {
|
||||
display: block;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
padding: 0 0 9px;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
}
|
||||
.workflow-choice:disabled {
|
||||
opacity: 0.65;
|
||||
cursor: default;
|
||||
}
|
||||
.family {
|
||||
font: 9px var(--mono);
|
||||
letter-spacing: 0.5px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.family span {
|
||||
font: 8px var(--font);
|
||||
padding: 2px 5px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 4px;
|
||||
}
|
||||
h3 {
|
||||
font-size: 11px;
|
||||
line-height: 1.7;
|
||||
margin: 0 0 9px;
|
||||
font-weight: 550;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
.card-meta {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 9px;
|
||||
color: var(--text-3);
|
||||
padding-right: 14px;
|
||||
}
|
||||
.favorite {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
font-size: 18px;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: #838a78;
|
||||
cursor: pointer;
|
||||
}
|
||||
.favorite.saved {
|
||||
color: var(--accent);
|
||||
}
|
||||
.tool-link {
|
||||
font-size: 10px;
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
.cloud-context {
|
||||
grid-column: 1/-1;
|
||||
background: #e9e7df;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.cloud-context h3 {
|
||||
font-size: 19px;
|
||||
}
|
||||
.cloud-context p {
|
||||
font-size: 11px;
|
||||
color: var(--text-2);
|
||||
line-height: 1.8;
|
||||
}
|
||||
.cloud-context .a-btn {
|
||||
font-size: 11px;
|
||||
}
|
||||
.pending {
|
||||
font-size: 10px;
|
||||
color: var(--text-3);
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--line);
|
||||
margin: 0;
|
||||
}
|
||||
.empty {
|
||||
grid-column: 1/-1;
|
||||
padding: 45px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: var(--text-3);
|
||||
font-size: var(--fs-mini);
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.more {
|
||||
align-self: center;
|
||||
margin: var(--sp-3) 0;
|
||||
grid-column: 1/-1;
|
||||
justify-self: center;
|
||||
font-size: 11px;
|
||||
}
|
||||
.bay-none,
|
||||
.bay-empty {
|
||||
margin: 0;
|
||||
padding: var(--sp-6) var(--sp-4);
|
||||
color: var(--text-3);
|
||||
font-size: var(--fs-aux);
|
||||
text-align: center;
|
||||
}
|
||||
.bay-empty {
|
||||
display: grid;
|
||||
justify-content: center;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
.bay-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-3) var(--sp-2) 0;
|
||||
border-top: 1px solid var(--line);
|
||||
font-size: var(--fs-mini);
|
||||
color: var(--text-3);
|
||||
}
|
||||
.pending-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
color: var(--text-2);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.pending-link:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
.active-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text-2);
|
||||
}
|
||||
.keys {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-1);
|
||||
margin-left: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.keys .a-kbd:not(:first-child) {
|
||||
margin-left: var(--sp-2);
|
||||
}
|
||||
.cloud-note {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: var(--sp-3);
|
||||
margin: var(--sp-4) var(--sp-2);
|
||||
padding: var(--sp-6);
|
||||
border: 1px dashed var(--line-2);
|
||||
border-radius: var(--r-lg);
|
||||
color: var(--text-2);
|
||||
}
|
||||
.cloud-title {
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
}
|
||||
.cloud-body {
|
||||
margin: 0;
|
||||
font-size: var(--fs-aux);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 窄/中屏:挑选台改为全屏浮层(计划中的最简可用降级)。 */
|
||||
.bay-backdrop {
|
||||
display: none;
|
||||
}
|
||||
@media (max-width: 1179px) {
|
||||
.bay {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: var(--topbar-h);
|
||||
bottom: 0;
|
||||
z-index: 60;
|
||||
background: var(--bg);
|
||||
box-shadow: var(--shadow-float);
|
||||
transform: translateY(12px);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition:
|
||||
transform var(--d-drawer) var(--ease-drawer),
|
||||
opacity var(--d-state) ease;
|
||||
@media (hover: hover) {
|
||||
.workflow-card:hover {
|
||||
border-color: var(--accent-line);
|
||||
}
|
||||
.bay.open {
|
||||
transform: none;
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.bay-backdrop {
|
||||
display: block;
|
||||
position: fixed;
|
||||
inset: var(--topbar-h) 0 0 0;
|
||||
z-index: 59;
|
||||
background: var(--overlay);
|
||||
}
|
||||
.close .lbl {
|
||||
display: inline;
|
||||
}
|
||||
.keys {
|
||||
display: none;
|
||||
}
|
||||
:global(:root[data-reduce='1']) .bay {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.bay {
|
||||
top: 0;
|
||||
padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + env(safe-area-inset-bottom));
|
||||
}
|
||||
.bay-backdrop {
|
||||
inset: 0;
|
||||
.categories button:hover {
|
||||
background: var(--bg-3);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,7 +5,13 @@
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
import ParamChip from './ParamChip.svelte';
|
||||
import SlotTray from './SlotTray.svelte';
|
||||
import { chipValue, type BlockReason, type DeskSchema, type FormValue, type FormValues } from './schema';
|
||||
import {
|
||||
chipValue,
|
||||
type BlockReason,
|
||||
type DeskSchema,
|
||||
type FormValue,
|
||||
type FormValues,
|
||||
} from './schema';
|
||||
|
||||
/**
|
||||
* 输入台 (spec-v2 §3.3): slots from the workflow JSON, the prompt, and one
|
||||
@@ -73,23 +79,48 @@
|
||||
const hasSlots = $derived(ds.slots.length + ds.lists.length > 0);
|
||||
const promptVal = $derived(ds.prompt ? String(values[ds.prompt.nodeId] ?? '') : '');
|
||||
const promptErr = $derived(showErrors && ds.prompt ? errors[ds.prompt.nodeId] : undefined);
|
||||
const endpointName = $derived(endpoints.find((e) => e.id === endpointId)?.name ?? t('desk.noConn'));
|
||||
const endpointName = $derived(
|
||||
endpoints.find((e) => e.id === endpointId)?.name ?? t('desk.noConn'),
|
||||
);
|
||||
|
||||
/** Composer chips: ratio, the width × height pair, resolution, duration, seed. */
|
||||
const chips = $derived.by(() => {
|
||||
const out: Array<{ key: string; inputs: ComfyDynamicInput[]; text: string }> = [];
|
||||
if (ds.ratio) out.push({ key: ds.ratio.nodeId, inputs: [ds.ratio], text: chipValue(ds.ratio, values, ds) });
|
||||
const out: Array<{
|
||||
key: string;
|
||||
inputs: ComfyDynamicInput[];
|
||||
text: string;
|
||||
}> = [];
|
||||
if (ds.ratio)
|
||||
out.push({
|
||||
key: ds.ratio.nodeId,
|
||||
inputs: [ds.ratio],
|
||||
text: chipValue(ds.ratio, values, ds),
|
||||
});
|
||||
if (ds.width && ds.height) {
|
||||
const w = values[ds.width.nodeId] ?? ds.width.defaultValue ?? '?';
|
||||
const h = values[ds.height.nodeId] ?? ds.height.defaultValue ?? '?';
|
||||
out.push({ key: ds.width.nodeId, inputs: [ds.width, ds.height], text: `${w}×${h}` });
|
||||
out.push({
|
||||
key: ds.width.nodeId,
|
||||
inputs: [ds.width, ds.height],
|
||||
text: `${w}×${h}`,
|
||||
});
|
||||
} else {
|
||||
for (const inp of [ds.width, ds.height]) {
|
||||
if (inp) out.push({ key: inp.nodeId, inputs: [inp], text: `${inp.label} ${chipValue(inp, values, ds)}` });
|
||||
if (inp)
|
||||
out.push({
|
||||
key: inp.nodeId,
|
||||
inputs: [inp],
|
||||
text: `${inp.label} ${chipValue(inp, values, ds)}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const inp of [ds.resolution, ds.duration, ds.seed]) {
|
||||
if (inp) out.push({ key: inp.nodeId, inputs: [inp], text: chipValue(inp, values, ds) });
|
||||
if (inp)
|
||||
out.push({
|
||||
key: inp.nodeId,
|
||||
inputs: [inp],
|
||||
text: chipValue(inp, values, ds),
|
||||
});
|
||||
}
|
||||
return out;
|
||||
});
|
||||
@@ -140,7 +171,16 @@
|
||||
>
|
||||
{#if hasSlots}
|
||||
<div class="slots">
|
||||
<SlotTray bind:this={tray} bind:busy={slotBusy} {ds} {values} {showErrors} {errors} {onSet} {onFromResults} />
|
||||
<SlotTray
|
||||
bind:this={tray}
|
||||
bind:busy={slotBusy}
|
||||
{ds}
|
||||
{values}
|
||||
{showErrors}
|
||||
{errors}
|
||||
{onSet}
|
||||
{onFromResults}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -158,7 +198,9 @@
|
||||
aria-keyshortcuts="Control+Enter Meta+Enter /"
|
||||
oninput={(e) => onSet(ds.prompt!.nodeId, e.currentTarget.value)}
|
||||
></textarea>
|
||||
{#if promptErr}<p class="a-slot-hint err prompt-err" role="alert">{promptErr}</p>{/if}
|
||||
{#if promptErr}<p class="a-slot-hint err prompt-err" role="alert">
|
||||
{promptErr}
|
||||
</p>{/if}
|
||||
{:else if current}
|
||||
<p class="no-prompt">{t('desk.noPromptInput')}</p>
|
||||
{/if}
|
||||
@@ -187,9 +229,17 @@
|
||||
title={t('studio.connLabel')}
|
||||
onclick={() => (connOpen = !connOpen)}
|
||||
>
|
||||
<span class="status-chip-dot {conn.state === 'ok' ? 'run' : conn.state === 'fail' ? 'fail' : 'idle'}"></span>
|
||||
<span
|
||||
class="status-chip-dot {conn.state === 'ok'
|
||||
? 'run'
|
||||
: conn.state === 'fail'
|
||||
? 'fail'
|
||||
: 'idle'}"
|
||||
></span>
|
||||
<span class="lbl">{endpointName}</span>
|
||||
{#if conn.state === 'ok' && conn.ms != null}<span class="mono">· {Math.round(conn.ms)} ms</span>{/if}
|
||||
{#if conn.state === 'ok' && conn.ms != null}<span class="mono"
|
||||
>· {Math.round(conn.ms)} ms</span
|
||||
>{/if}
|
||||
{#if conn.state === 'dry'}<span>· {t('desk.dryRun')}</span>{/if}
|
||||
</button>
|
||||
<ShellPop bind:open={connOpen} label={t('studio.connLabel')} placement="top" width="280px">
|
||||
@@ -225,7 +275,12 @@
|
||||
</div>
|
||||
{/each}
|
||||
{#if ds.common.length + ds.advanced.length > 0}
|
||||
<button type="button" class="a-chip opt" class:changed={changedCount > 0} onclick={onOpenParams}>
|
||||
<button
|
||||
type="button"
|
||||
class="a-chip opt"
|
||||
class:changed={changedCount > 0}
|
||||
onclick={onOpenParams}
|
||||
>
|
||||
<Icon name="settings" size={14} />
|
||||
<span class="lbl">
|
||||
{changedCount > 0 ? t('desk.paramsChanged', { n: changedCount }) : t('desk.paramsAll')}
|
||||
@@ -249,7 +304,9 @@
|
||||
onclick={onSubmit}
|
||||
>
|
||||
<span class="l-idle"><Icon name="sparkle" size={13} />{t('desk.generate')}</span>
|
||||
<span class="l-sent" aria-hidden={!sent}><Icon name="check" size={13} />{t('desk.sent')}</span>
|
||||
<span class="l-sent" aria-hidden={!sent}
|
||||
><Icon name="check" size={13} />{t('desk.sent')}</span
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -421,4 +478,86 @@
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
}
|
||||
|
||||
.composer-wrap {
|
||||
margin: 16px 0 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
}
|
||||
.composer {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
border-radius: 0;
|
||||
}
|
||||
.prompt {
|
||||
min-height: 142px;
|
||||
width: 100%;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--line);
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
resize: vertical;
|
||||
box-sizing: border-box;
|
||||
order: -1;
|
||||
}
|
||||
.slots {
|
||||
padding: 0;
|
||||
}
|
||||
.foot {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 12px;
|
||||
}
|
||||
.picker {
|
||||
display: none;
|
||||
}
|
||||
.opt,
|
||||
.conn {
|
||||
width: 100%;
|
||||
}
|
||||
.opt :global(.a-chip),
|
||||
.conn :global(.a-chip) {
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
border-radius: 7px;
|
||||
padding: 9px 10px;
|
||||
background: var(--bg);
|
||||
font-size: 11px;
|
||||
min-height: 35px;
|
||||
}
|
||||
.submit {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
.gen {
|
||||
width: 100%;
|
||||
height: 43px;
|
||||
font-size: 12px;
|
||||
justify-content: space-between;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.why {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
line-height: 1.7;
|
||||
max-width: none;
|
||||
}
|
||||
.lbl {
|
||||
max-width: 100%;
|
||||
}
|
||||
.prompt-err {
|
||||
order: -1;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import ImageLightbox from '$lib/components/ImageLightbox.svelte';
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import { assetUrl } from '$lib/api';
|
||||
import type { Job, Workflow } from '$lib/comfy/types';
|
||||
import { progressFor } from '$lib/jobProgress';
|
||||
import { jobStatusInfo } from '$lib/jobStatus';
|
||||
import { parseDbTs } from '$lib/dbtime';
|
||||
import { clearOutputMissing, markOutputMissing, missingOutputsOf } from '$lib/missingOutputs.svelte';
|
||||
import {
|
||||
clearOutputMissing,
|
||||
markOutputMissing,
|
||||
missingOutputsOf,
|
||||
} from '$lib/missingOutputs.svelte';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
import { exportLastFrame } from '$lib/media/lastFrame';
|
||||
import { usageLabel } from './schema';
|
||||
@@ -23,6 +28,8 @@
|
||||
* shows the amber 文件缺失 state with 用相同参数重做 / 移除记录.
|
||||
*/
|
||||
interface Props {
|
||||
main?: boolean;
|
||||
comparePath?: string | null;
|
||||
tab: 'result' | 'params';
|
||||
job: Job | null;
|
||||
wf: Workflow | undefined;
|
||||
@@ -47,6 +54,8 @@
|
||||
}
|
||||
|
||||
let {
|
||||
main = false,
|
||||
comparePath = null,
|
||||
tab = $bindable(),
|
||||
job,
|
||||
wf,
|
||||
@@ -66,6 +75,14 @@
|
||||
}: Props = $props();
|
||||
|
||||
let outIndex = $state(0);
|
||||
let compare = $state(false),
|
||||
compareAt = $state(50),
|
||||
lightbox = $state(false);
|
||||
$effect(() => {
|
||||
void job?.id;
|
||||
compare = false;
|
||||
lightbox = false;
|
||||
});
|
||||
$effect.pre(() => {
|
||||
void job?.id;
|
||||
outIndex = 0;
|
||||
@@ -76,16 +93,20 @@
|
||||
// cannot be fetched — the failed case stays red.
|
||||
const gonePaths = $derived(missingOutputsOf(job));
|
||||
const fileGone = $derived(gonePaths.length > 0);
|
||||
const outputs = $derived(job && st?.tone === 'ok' ? job.output_paths.filter((p) => !gonePaths.includes(p)) : []);
|
||||
const outputs = $derived(
|
||||
job && st?.tone === 'ok' ? job.output_paths.filter((p) => !gonePaths.includes(p)) : [],
|
||||
);
|
||||
const output = $derived(outputs[Math.min(outIndex, outputs.length - 1)] ?? null);
|
||||
const allOutputs = $derived(job && st?.tone === 'ok' ? job.output_paths : []);
|
||||
const video = $derived(!!job && !!output && isVideoOutput(job, output));
|
||||
const wfDeleted = $derived(!!job && job.workflow_id == null);
|
||||
const prompt = $derived(job ? promptOf(job, wf) : '');
|
||||
const inputs = $derived(job ? inputsOf(job, wf) : []);
|
||||
const compareSource = $derived(inputs.find((i) => i.kind === 'image')?.path ?? comparePath);
|
||||
const spec = $derived(job ? specOf(job, wf) : []);
|
||||
const endpoint = $derived(
|
||||
((job?.payload?.endpoint as Record<string, unknown> | undefined)?.name as string | undefined) ?? '',
|
||||
((job?.payload?.endpoint as Record<string, unknown> | undefined)?.name as string | undefined) ??
|
||||
'',
|
||||
);
|
||||
const progress = $derived.by(() => {
|
||||
if (!job || job.status !== 'running') return 0;
|
||||
@@ -144,14 +165,23 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<aside class="inspector" class:open inert={inactive} aria-label={t('desk.inspector')}>
|
||||
<aside class="inspector" class:main class:open inert={inactive} aria-label={t('desk.inspector')}>
|
||||
<div class="tabs">
|
||||
<div class="a-seg" role="group" aria-label={t('desk.inspector')}>
|
||||
<button type="button" aria-pressed={tab === 'result'} onclick={() => (tab = 'result')}>{t('desk.tabResult')}</button>
|
||||
<button type="button" aria-pressed={tab === 'params'} onclick={() => (tab = 'params')}>{t('desk.tabParams')}</button>
|
||||
<button type="button" aria-pressed={tab === 'result'} onclick={() => (tab = 'result')}
|
||||
>{t('desk.tabResult')}</button
|
||||
>
|
||||
<button type="button" aria-pressed={tab === 'params'} onclick={() => (tab = 'params')}
|
||||
>{t('desk.tabParams')}</button
|
||||
>
|
||||
</div>
|
||||
<span class="keys"><span class="a-kbd">]</span>{t('desk.keyInspector')}</span>
|
||||
<button type="button" class="a-btn ghost sm close" aria-label={t('desk.closeInspector')} onclick={onClose}>
|
||||
<button
|
||||
type="button"
|
||||
class="a-btn ghost sm close"
|
||||
aria-label={t('desk.closeInspector')}
|
||||
onclick={onClose}
|
||||
>
|
||||
<Icon name="close" size={14} />
|
||||
</button>
|
||||
</div>
|
||||
@@ -160,7 +190,13 @@
|
||||
{#if tab === 'params'}
|
||||
{@render params()}
|
||||
{:else if !job || !st}
|
||||
<div class="a-stage stage"><div class="stage-empty">{t('desk.pickTake')}</div></div>
|
||||
<div class="a-stage stage">
|
||||
<div class="stage-empty">
|
||||
<span class="empty-symbol">✳</span><strong>给想象留一个位置。</strong><span class="sub"
|
||||
>在右侧写下描述,或选择一次已有创作。</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="a-stage stage">
|
||||
{#key mediaKey}
|
||||
@@ -194,6 +230,13 @@
|
||||
}}
|
||||
onerror={() => output && markOutputMissing(output)}
|
||||
/>
|
||||
{#if main && compare && compareSource}<div
|
||||
class="comparison-layer"
|
||||
style:clip-path={`inset(0 ${100 - compareAt}% 0 0)`}
|
||||
>
|
||||
<img src={assetUrl(compareSource)} alt="对比参考画面" />
|
||||
</div>
|
||||
<div class="comparison-divider" style:left={`${compareAt}%`}></div>{/if}
|
||||
</div>
|
||||
{:else if fileGone}
|
||||
<div class="stage-empty gone">
|
||||
@@ -205,7 +248,9 @@
|
||||
<span>{st.label}</span>
|
||||
<span class="sub">{st.tone === 'fail' ? t('desk.notGenerated') : st.detail}</span>
|
||||
{#if progress > 0}
|
||||
<div class="a-progress stage-bar" style:--p={progress / 100}><i></i></div>
|
||||
<div class="a-progress stage-bar" style:--p={progress / 100}>
|
||||
<i></i>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -241,16 +286,42 @@
|
||||
<span>{s.label} <b class="mono">{s.value}</b></span>
|
||||
{/if}
|
||||
{/each}
|
||||
<span>{t('desk.elapsed')} <b class="mono">{fmtDur(elapsedSec(job, nowMs))}</b></span>
|
||||
<span
|
||||
>{t('desk.elapsed')}
|
||||
<b class="mono">{fmtDur(elapsedSec(job, nowMs))}</b></span
|
||||
>
|
||||
{#if endpoint}<span>{endpoint}</span>{/if}
|
||||
</div>
|
||||
|
||||
{#if main && compare && output && !video}<div class="compare-controls">
|
||||
<span>{inputs.some((i) => i.kind === 'image') ? '参考图片' : '上一版'}</span><input
|
||||
type="range"
|
||||
min="0"
|
||||
max="100"
|
||||
bind:value={compareAt}
|
||||
aria-label="拖动对比画面"
|
||||
/><span>当前结果</span>
|
||||
</div>{/if}
|
||||
<div class="actions">
|
||||
{#if main && output && !video}<button
|
||||
class="a-btn secondary sm"
|
||||
onclick={() => (lightbox = true)}>放大查看 ⤢</button
|
||||
>{#if compareSource && compareSource !== output}<button
|
||||
class="a-btn secondary sm"
|
||||
aria-pressed={compare}
|
||||
onclick={() => (compare = !compare)}>{compare ? '结束对比' : '对比画面'} ◫</button
|
||||
>{/if}{/if}
|
||||
{#if fileGone && !outputs.length}
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onRetry(job)}>{t('desk.redo')}</button>
|
||||
<button type="button" class="a-btn danger sm" onclick={() => onDelete(job)}>{t('desk.removeRecord')}</button>
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onRetry(job)}
|
||||
>{t('desk.redo')}</button
|
||||
>
|
||||
<button type="button" class="a-btn danger sm" onclick={() => onDelete(job)}
|
||||
>{t('desk.removeRecord')}</button
|
||||
>
|
||||
{:else}
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onReuse(job)}>{t('desk.reuseToComposer')}</button>
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onReuse(job)}
|
||||
>{t('desk.reuseToComposer')}</button
|
||||
>
|
||||
{#if output && !video && canSendToSlot}
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onSendToSlot(output)}>
|
||||
{t('desk.sendToSlot')}
|
||||
@@ -272,10 +343,14 @@
|
||||
</button>
|
||||
{/if}
|
||||
{#if st.tone === 'fail'}
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onRetry(job)}>{t('common.retry')}</button>
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onRetry(job)}
|
||||
>{t('common.retry')}</button
|
||||
>
|
||||
{/if}
|
||||
{#if job.status !== 'pending' && job.status !== 'running'}
|
||||
<button type="button" class="a-btn danger sm" onclick={() => onDelete(job)}>{t('studio.deleteBtn')}</button>
|
||||
<button type="button" class="a-btn danger sm" onclick={() => onDelete(job)}
|
||||
>{t('studio.deleteBtn')}</button
|
||||
>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
@@ -286,44 +361,61 @@
|
||||
<div class="note warn" role="alert">{t('jobst.missingDetail')}</div>
|
||||
{/if}
|
||||
|
||||
{#if inputs.length || prompt}
|
||||
<div class="section-title">{t('desk.inputs')}</div>
|
||||
{#if inputs.length}
|
||||
<div class="inputs">
|
||||
{#each inputs as inp (inp.label + inp.path)}
|
||||
{#if inp.kind === 'image'}
|
||||
<img class="mini" src={assetUrl(inp.path)} alt={inp.label} title={inp.label} loading="lazy" />
|
||||
{:else}
|
||||
<span class="mini glyph" title={inp.label}><Icon name={inp.kind === 'video' ? 'film' : 'music'} size={14} /></span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
<details class="result-details">
|
||||
<summary>创作详情与参数</summary>
|
||||
{#if inputs.length || prompt}
|
||||
<div class="section-title">{t('desk.inputs')}</div>
|
||||
{#if inputs.length}
|
||||
<div class="inputs">
|
||||
{#each inputs as inp (inp.label + inp.path)}
|
||||
{#if inp.kind === 'image'}
|
||||
<img
|
||||
class="mini"
|
||||
src={assetUrl(inp.path)}
|
||||
alt={inp.label}
|
||||
title={inp.label}
|
||||
loading="lazy"
|
||||
/>
|
||||
{:else}
|
||||
<span class="mini glyph" title={inp.label}
|
||||
><Icon name={inp.kind === 'video' ? 'film' : 'music'} size={14} /></span
|
||||
>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{#if prompt}<p class="prompt">{prompt}</p>{/if}
|
||||
{/if}
|
||||
{#if prompt}<p class="prompt">{prompt}</p>{/if}
|
||||
{/if}
|
||||
|
||||
<div class="section-title">{t('desk.workflow')}</div>
|
||||
<dl class="kv">
|
||||
<dt>{t('desk.kvName')}</dt>
|
||||
<dd>
|
||||
{wf?.name ?? t('studio.jobName', { id: job.id })}
|
||||
{#if wfDeleted}<span class="a-tag wf-gone">{t('studio.wfDeletedTag')}</span>{/if}
|
||||
</dd>
|
||||
{#if wf?.usage}
|
||||
<dt>{t('desk.kvUsage')}</dt>
|
||||
<dd>{usageLabel(wf.usage)}</dd>
|
||||
{/if}
|
||||
<dt>{t('desk.kvCreated')}</dt>
|
||||
<dd class="mono">{fmtClock(parseDbTs(job.created_at))}</dd>
|
||||
{#if job.comfy_prompt_id}
|
||||
<dt>{t('desk.kvPromptId')}</dt>
|
||||
<dd class="mono">{job.comfy_prompt_id}</dd>
|
||||
{/if}
|
||||
</dl>
|
||||
<div class="section-title">{t('desk.workflow')}</div>
|
||||
<dl class="kv">
|
||||
<dt>{t('desk.kvName')}</dt>
|
||||
<dd>
|
||||
{wf?.name ?? t('studio.jobName', { id: job.id })}
|
||||
{#if wfDeleted}<span class="a-tag wf-gone">{t('studio.wfDeletedTag')}</span>{/if}
|
||||
</dd>
|
||||
{#if wf?.usage}
|
||||
<dt>{t('desk.kvUsage')}</dt>
|
||||
<dd>{usageLabel(wf.usage)}</dd>
|
||||
{/if}
|
||||
<dt>{t('desk.kvCreated')}</dt>
|
||||
<dd class="mono">{fmtClock(parseDbTs(job.created_at))}</dd>
|
||||
{#if job.comfy_prompt_id}
|
||||
<dt>{t('desk.kvPromptId')}</dt>
|
||||
<dd class="mono">{job.comfy_prompt_id}</dd>
|
||||
{/if}
|
||||
</dl>
|
||||
</details>
|
||||
{/if}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{#if lightbox && output && !video}<ImageLightbox
|
||||
src={assetUrl(output) ?? ''}
|
||||
alt={prompt || '创作结果'}
|
||||
onClose={() => (lightbox = false)}
|
||||
/>{/if}
|
||||
|
||||
<style>
|
||||
.inspector {
|
||||
display: flex;
|
||||
@@ -578,4 +670,138 @@
|
||||
padding: var(--sp-5);
|
||||
}
|
||||
}
|
||||
|
||||
.inspector.main {
|
||||
position: static;
|
||||
inset: auto;
|
||||
transform: none;
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
overflow: visible;
|
||||
box-shadow: none;
|
||||
}
|
||||
.main .tabs {
|
||||
display: none;
|
||||
}
|
||||
.main .body {
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
.main .stage {
|
||||
aspect-ratio: auto;
|
||||
width: 100%;
|
||||
min-height: 365px;
|
||||
height: 44vh;
|
||||
max-height: 580px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
background: #eae9e3;
|
||||
}
|
||||
.main .stage-media {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.main .print {
|
||||
max-height: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
}
|
||||
.main .print img,
|
||||
.main .print video {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
object-fit: contain;
|
||||
border-radius: 0;
|
||||
}
|
||||
.main .a-fix {
|
||||
display: none;
|
||||
}
|
||||
.main .stage-empty {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: var(--text-3);
|
||||
font-size: 12px;
|
||||
}
|
||||
.empty-symbol {
|
||||
color: var(--accent);
|
||||
font-size: 55px;
|
||||
font-weight: 300;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.stage-empty strong {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
}
|
||||
.main .meta {
|
||||
font-size: 9px;
|
||||
gap: 12px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.main .actions {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.result-details {
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
margin-top: 12px;
|
||||
}
|
||||
.result-details summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
.result-details .prompt {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.comparison-layer {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.comparison-layer img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
background: #eae9e3;
|
||||
}
|
||||
.comparison-divider {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 2px;
|
||||
background: var(--surface);
|
||||
box-shadow: 0 0 8px #292a2d40;
|
||||
pointer-events: none;
|
||||
}
|
||||
.compare-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
font-size: 10px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
.compare-controls input {
|
||||
flex: 1;
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,19 +45,11 @@
|
||||
}
|
||||
|
||||
// Spec §2.1 allows the five avatar gradients as cover placeholders.
|
||||
const PLACEHOLDER_GRADIENTS = [
|
||||
'var(--avatar-1)',
|
||||
'var(--avatar-2)',
|
||||
'var(--avatar-3)',
|
||||
'var(--avatar-4)',
|
||||
'var(--avatar-5)',
|
||||
];
|
||||
const PLACEHOLDER_GRADIENTS = ['#e8e6da', '#dae0e8', '#e9cfc4', '#e1e6c4', '#dcd3e2'];
|
||||
const placeholderIdx = $derived(project.id % PLACEHOLDER_GRADIENTS.length);
|
||||
const placeholder = $derived(PLACEHOLDER_GRADIENTS[placeholderIdx]);
|
||||
// HEL-680 灰阶封面占位:1–2 亮阶配深图标,3–5 暗阶配浅图标
|
||||
const placeholderIconColor = $derived(
|
||||
placeholderIdx <= 1 ? 'var(--accent-ink)' : 'var(--text)',
|
||||
);
|
||||
const placeholderIconColor = $derived('var(--text-2)');
|
||||
|
||||
const coverUrl = $derived(assetUrl(project.cover_path));
|
||||
|
||||
@@ -73,13 +65,22 @@
|
||||
const state = current ? stats.stage_status?.[current] : undefined;
|
||||
const stageName = current ? t(`workbench.stage.${current}`) : '';
|
||||
if (state === 'running') {
|
||||
return { cls: 'st-progress', label: `${stageName} · ${t('workbench.state.running')}` };
|
||||
return {
|
||||
cls: 'st-progress',
|
||||
label: `${stageName} · ${t('workbench.state.running')}`,
|
||||
};
|
||||
}
|
||||
if (state === 'awaiting_confirm') {
|
||||
return { cls: 'st-pending', label: `${stageName} · ${t('workbench.state.draft')}` };
|
||||
return {
|
||||
cls: 'st-pending',
|
||||
label: `${stageName} · ${t('workbench.state.draft')}`,
|
||||
};
|
||||
}
|
||||
if (stats.stage_confirmed > 0) {
|
||||
return { cls: 'st-progress', label: `${stageName} · ${t('home.statusProgress')}` };
|
||||
return {
|
||||
cls: 'st-progress',
|
||||
label: `${stageName} · ${t('home.statusProgress')}`,
|
||||
};
|
||||
}
|
||||
return { cls: 'st-draft', label: t('home.statusDraft') };
|
||||
});
|
||||
@@ -185,7 +186,9 @@
|
||||
style:color={placeholderIconColor}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<Icon name="film" size={22} />
|
||||
<span class="cover-type"
|
||||
>✳<small>STORY / {String(project.id).padStart(3, '0')}</small></span
|
||||
>
|
||||
</span>
|
||||
{/if}
|
||||
<span class="status-tag {cover.cls}">{cover.label}</span>
|
||||
@@ -534,9 +537,81 @@
|
||||
}
|
||||
.menu-item.danger:hover {
|
||||
background: var(--error-dim);
|
||||
} .a-card :global(.field-input) {
|
||||
}
|
||||
.a-card :global(.field-input) {
|
||||
background: var(--surface-2);
|
||||
border-color: var(--border-strong);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.a-card {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
.cover {
|
||||
height: 180px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.body {
|
||||
padding: 12px 0 0;
|
||||
}
|
||||
.status-tag {
|
||||
top: auto;
|
||||
left: 12px;
|
||||
right: auto;
|
||||
bottom: 12px;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 4px 7px;
|
||||
background: #fbfaf7ed;
|
||||
color: var(--text);
|
||||
font-size: 9px;
|
||||
}
|
||||
.cover-type {
|
||||
font-size: 56px;
|
||||
font-weight: 300;
|
||||
color: #777b70;
|
||||
}
|
||||
.cover-type small {
|
||||
display: block;
|
||||
font: 9px var(--mono);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
.cover-img {
|
||||
transition: transform 250ms var(--ease-out);
|
||||
}
|
||||
.stage-bar {
|
||||
width: 100%;
|
||||
}
|
||||
.seg {
|
||||
flex: 1;
|
||||
height: 3px;
|
||||
}
|
||||
.meta-stats,
|
||||
.meta-time {
|
||||
font-size: 10px;
|
||||
}
|
||||
.idea {
|
||||
font-size: 11px;
|
||||
min-height: 0;
|
||||
}
|
||||
.menu-wrap {
|
||||
left: auto;
|
||||
right: 10px;
|
||||
}
|
||||
.menu-btn {
|
||||
background: var(--surface);
|
||||
}
|
||||
.menu {
|
||||
left: auto;
|
||||
right: 0;
|
||||
box-shadow: var(--shadow-float);
|
||||
}
|
||||
@media (hover: hover) {
|
||||
.a-card:hover .cover-img {
|
||||
transform: scale(1.035);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
let { onStart, onImport }: { onStart: () => void; onImport: () => void } = $props();
|
||||
let card: HTMLDivElement;
|
||||
onMount(() => {
|
||||
let raf = 0,
|
||||
x = 0,
|
||||
v = 0,
|
||||
target = 0,
|
||||
time = 0;
|
||||
const reduced = () =>
|
||||
window.matchMedia('(prefers-reduced-motion: reduce)').matches ||
|
||||
document.documentElement.dataset.reduce === '1';
|
||||
function animate(now: number) {
|
||||
const dt = Math.min((now - time) / 1000 || 0.016, 0.032);
|
||||
time = now;
|
||||
v += ((target - x) * 100 - v * 10) * dt;
|
||||
x += v * dt;
|
||||
card.style.transform = `rotate(${10 + x}deg) translateY(${-Math.abs(x)}px)`;
|
||||
if (Math.abs(v) + Math.abs(target - x) > 0.01) raf = requestAnimationFrame(animate);
|
||||
else raf = 0;
|
||||
}
|
||||
function go(value: number) {
|
||||
if (reduced()) return;
|
||||
target = value;
|
||||
if (!raf) {
|
||||
time = performance.now();
|
||||
raf = requestAnimationFrame(animate);
|
||||
}
|
||||
}
|
||||
const enter = () => go(-5),
|
||||
leave = () => go(0);
|
||||
card.addEventListener('pointerenter', enter);
|
||||
card.addEventListener('pointerleave', leave);
|
||||
return () => {
|
||||
cancelAnimationFrame(raf);
|
||||
card.removeEventListener('pointerenter', enter);
|
||||
card.removeEventListener('pointerleave', leave);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<section class="refract-hero">
|
||||
<div class="hero-copy">
|
||||
<div class="eyebrow">● A SPACE FOR THE UNEXPECTED</div>
|
||||
<h1>让想象,<br /><span>在这里成形。</span></h1>
|
||||
<p>
|
||||
从一个念头,到一组画面,再到一段故事。<br />你的模型、素材与灵感,都在同一个工作室。
|
||||
</p>
|
||||
<div class="hero-buttons">
|
||||
<button class="a-btn primary" onclick={onStart}>开始创作 →</button><button
|
||||
class="text-button"
|
||||
onclick={onImport}>导入已有剧本 ↗</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-art">
|
||||
<img class="hero-photo" src="/refract/coast.jpg" alt="海岸与薄雾构成的灵感画面" />
|
||||
<div class="art-circle"></div>
|
||||
<span class="hero-star">✳</span>
|
||||
<div class="art-label">
|
||||
VISUAL STUDY / 001<br />LIGHT, SPACE & POSSIBILITY
|
||||
</div>
|
||||
<div class="hero-card" bind:this={card}>
|
||||
<img src="/refract/arch.jpg" alt="建筑几何参考" /><span>FOUND IN THE IN-BETWEEN</span>
|
||||
</div>
|
||||
<div class="art-word">Beyond<br />the ordinary.</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.refract-hero {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.12fr;
|
||||
min-height: 322px;
|
||||
border-radius: 18px;
|
||||
background: #e9e7df;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.hero-copy {
|
||||
padding: 35px 40px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
.eyebrow {
|
||||
color: var(--accent);
|
||||
font-size: 9px;
|
||||
letter-spacing: 1.3px;
|
||||
margin-bottom: 19px;
|
||||
}
|
||||
h1 {
|
||||
font-size: clamp(33px, 3vw, 47px);
|
||||
line-height: 1.3;
|
||||
margin: 0 0 15px;
|
||||
font-weight: 650;
|
||||
letter-spacing: -1.6px;
|
||||
}
|
||||
h1 span {
|
||||
color: var(--accent);
|
||||
}
|
||||
p {
|
||||
font-size: 12px;
|
||||
line-height: 1.9;
|
||||
color: #71736b;
|
||||
margin: 0 0 23px;
|
||||
}
|
||||
.hero-buttons {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
.hero-buttons .a-btn {
|
||||
height: 41px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
.text-button {
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--text-2);
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.hero-art {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: #d2dbe4;
|
||||
min-height: 322px;
|
||||
isolation: isolate;
|
||||
}
|
||||
.hero-photo {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center 70%;
|
||||
filter: contrast(0.92) saturate(0.7);
|
||||
}
|
||||
.art-circle {
|
||||
position: absolute;
|
||||
width: 270px;
|
||||
height: 270px;
|
||||
border: 1px solid #ffffff88;
|
||||
border-radius: 50%;
|
||||
top: 28px;
|
||||
left: 75px;
|
||||
z-index: 1;
|
||||
}
|
||||
.art-circle:before,
|
||||
.art-circle:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
border: 1px solid #ffffff66;
|
||||
border-radius: 50%;
|
||||
inset: 26px;
|
||||
}
|
||||
.art-circle:after {
|
||||
inset: 57px;
|
||||
}
|
||||
.art-word {
|
||||
position: absolute;
|
||||
bottom: 22px;
|
||||
left: 23px;
|
||||
z-index: 2;
|
||||
font-family: Georgia, serif;
|
||||
font-size: 64px;
|
||||
color: white;
|
||||
line-height: 0.8;
|
||||
font-style: italic;
|
||||
letter-spacing: -4px;
|
||||
}
|
||||
.art-label {
|
||||
position: absolute;
|
||||
top: 21px;
|
||||
right: 22px;
|
||||
z-index: 2;
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
text-align: right;
|
||||
letter-spacing: 1.4px;
|
||||
}
|
||||
.hero-card {
|
||||
position: absolute;
|
||||
right: 27px;
|
||||
top: 60px;
|
||||
width: 145px;
|
||||
height: 188px;
|
||||
border: 5px solid var(--surface);
|
||||
background: var(--surface);
|
||||
box-shadow: 0 20px 30px #1b2a3530;
|
||||
transform: rotate(10deg);
|
||||
z-index: 3;
|
||||
}
|
||||
.hero-card img {
|
||||
width: 100%;
|
||||
height: 155px;
|
||||
object-fit: cover;
|
||||
}
|
||||
.hero-card span {
|
||||
font-family: monospace;
|
||||
letter-spacing: 0.4px;
|
||||
font-size: 8px;
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.hero-star {
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 57px;
|
||||
color: var(--lime);
|
||||
font-size: 65px;
|
||||
line-height: 1;
|
||||
z-index: 2;
|
||||
}
|
||||
@media (max-width: 1250px) {
|
||||
.hero-copy {
|
||||
padding: 28px;
|
||||
}
|
||||
.hero-copy h1 {
|
||||
font-size: 35px;
|
||||
}
|
||||
.hero-buttons {
|
||||
gap: 10px;
|
||||
}
|
||||
.hero-card {
|
||||
width: 125px;
|
||||
height: 164px;
|
||||
right: 18px;
|
||||
}
|
||||
.hero-card img {
|
||||
height: 131px;
|
||||
}
|
||||
.art-circle {
|
||||
left: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,9 @@ export type NavId =
|
||||
| 'connections'
|
||||
| 'models'
|
||||
| 'library'
|
||||
| 'settings';
|
||||
| 'settings'
|
||||
| 'canvas'
|
||||
| 'workflows';
|
||||
|
||||
export interface NavItem {
|
||||
id: NavId;
|
||||
@@ -24,18 +26,55 @@ export interface NavItem {
|
||||
// and settings entries at the foot of the 60px rail.
|
||||
export const NAV_MAIN: NavItem[] = [
|
||||
{ id: 'projects', labelKey: 'shell.navProjects', icon: 'home', href: '/' },
|
||||
{ id: 'workbench', labelKey: 'shell.navWorkbench', icon: 'story', href: '/workbench' },
|
||||
{
|
||||
id: 'workbench',
|
||||
labelKey: 'shell.navWorkbench',
|
||||
icon: 'story',
|
||||
href: '/workbench',
|
||||
},
|
||||
{ id: 'image', labelKey: 'shell.navImage', icon: 'image', href: '/image' },
|
||||
{ id: 'video', labelKey: 'shell.navVideo', icon: 'film', href: '/video' },
|
||||
{ id: 'tasks', labelKey: 'shell.navTasks', icon: 'queue', href: '/tasks' },
|
||||
{ id: 'agents', labelKey: 'shell.navAgents', icon: 'sparkle', href: '/agents' },
|
||||
{ id: 'canvas', labelKey: 'nav.canvas', icon: 'story', href: '/canvas' },
|
||||
{
|
||||
id: 'agents',
|
||||
labelKey: 'shell.navAgents',
|
||||
icon: 'sparkle',
|
||||
href: '/agents',
|
||||
},
|
||||
];
|
||||
|
||||
export const NAV_FOOT: NavItem[] = [
|
||||
{ id: 'connections', labelKey: 'shell.navConnections', icon: 'link', href: '/connections' },
|
||||
{ id: 'models', labelKey: 'shell.navModels', icon: 'assets', href: '/models' },
|
||||
{ id: 'library', labelKey: 'shell.navLibrary', icon: 'folder', href: '/library' },
|
||||
{ id: 'settings', labelKey: 'shell.navSettings', icon: 'settings', href: '/settings' },
|
||||
{
|
||||
id: 'connections',
|
||||
labelKey: 'shell.navConnections',
|
||||
icon: 'link',
|
||||
href: '/connections',
|
||||
},
|
||||
{
|
||||
id: 'models',
|
||||
labelKey: 'shell.navModels',
|
||||
icon: 'assets',
|
||||
href: '/models',
|
||||
},
|
||||
{
|
||||
id: 'workflows',
|
||||
labelKey: 'connections.wfTitle',
|
||||
icon: 'playground',
|
||||
href: '/workflows',
|
||||
},
|
||||
{
|
||||
id: 'library',
|
||||
labelKey: 'shell.navLibrary',
|
||||
icon: 'folder',
|
||||
href: '/library',
|
||||
},
|
||||
{
|
||||
id: 'settings',
|
||||
labelKey: 'shell.navSettings',
|
||||
icon: 'settings',
|
||||
href: '/settings',
|
||||
},
|
||||
];
|
||||
|
||||
export const NAV: NavItem[] = [...NAV_MAIN, ...NAV_FOOT];
|
||||
@@ -51,8 +90,20 @@ export interface TabItem {
|
||||
|
||||
/** ≤760px bottom tab bar (§二): 项目 / 创作 / 生成 / 更多. */
|
||||
export const TABS: TabItem[] = [
|
||||
{ id: 'projects', labelKey: 'shell.tabProjects', icon: 'home', href: '/', covers: ['projects'] },
|
||||
{ id: 'workbench', labelKey: 'shell.tabCreate', icon: 'story', href: '/workbench', covers: ['workbench'] },
|
||||
{
|
||||
id: 'projects',
|
||||
labelKey: 'shell.tabProjects',
|
||||
icon: 'home',
|
||||
href: '/',
|
||||
covers: ['projects'],
|
||||
},
|
||||
{
|
||||
id: 'workbench',
|
||||
labelKey: 'shell.tabCreate',
|
||||
icon: 'story',
|
||||
href: '/workbench',
|
||||
covers: ['workbench'],
|
||||
},
|
||||
{
|
||||
id: 'generate',
|
||||
labelKey: 'shell.tabGenerate',
|
||||
|
||||
@@ -23,22 +23,6 @@
|
||||
return t(`workbench.stage.${key}`);
|
||||
}
|
||||
|
||||
function charOf(key: string): string {
|
||||
const map: Record<string, string> = {
|
||||
script: '剧',
|
||||
style: '视',
|
||||
storyboard: '分',
|
||||
assets: '素',
|
||||
shot: '镜',
|
||||
};
|
||||
return map[key] ?? key;
|
||||
}
|
||||
|
||||
function avatarVar(key: string): string {
|
||||
const idx = ORDER.indexOf(key) + 1;
|
||||
return `var(--avatar-${idx})`;
|
||||
}
|
||||
|
||||
function stateOf(stage: WorkbenchStage): 'todo' | 'running' | 'draft' | 'edited' | 'confirmed' {
|
||||
if (stage.status === 'running') return 'running';
|
||||
if (stage.status === 'confirmed' && !stage.draft_edited) return 'confirmed';
|
||||
@@ -82,12 +66,12 @@
|
||||
aria-current={activeKey === key ? 'step' : undefined}
|
||||
title={open ? label(key) : t('workbench.lockedStep', { stage: label(ORDER[i - 1]) })}
|
||||
>
|
||||
<span class="avatar" style:background={avatarVar(key)}>{charOf(key)}</span>
|
||||
<span class="avatar">{state === 'confirmed' ? '✓' : String(i + 1).padStart(2, '0')}</span>
|
||||
<span class="step-copy">
|
||||
<span class="step-name">{label(key)}</span>
|
||||
<span class="step-state st-{state}">
|
||||
{#if state === 'running'}<span class="breath" aria-hidden="true"></span>{/if}
|
||||
{stateLabel(stage!)}
|
||||
{stage ? stateLabel(stage) : t('workbench.state.todo')}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
@@ -238,4 +222,63 @@
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.stepper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 7px;
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
.step {
|
||||
display: block;
|
||||
}
|
||||
.bar {
|
||||
display: none;
|
||||
}
|
||||
.step-btn {
|
||||
width: 100%;
|
||||
padding: 12px 10px;
|
||||
border: 0;
|
||||
gap: 10px;
|
||||
}
|
||||
.avatar {
|
||||
width: 27px;
|
||||
height: 27px;
|
||||
background: none !important;
|
||||
border: 1px solid var(--line-2);
|
||||
border-radius: 50%;
|
||||
font: 9px var(--mono);
|
||||
color: var(--text-3);
|
||||
font-weight: 400;
|
||||
}
|
||||
.step-btn.active {
|
||||
background: #e8eafe;
|
||||
box-shadow: none;
|
||||
}
|
||||
.step-btn.active .avatar {
|
||||
background: var(--accent) !important;
|
||||
border-color: var(--accent);
|
||||
color: white;
|
||||
}
|
||||
.step-name {
|
||||
font-size: 11px;
|
||||
font-weight: 550;
|
||||
}
|
||||
.step-state {
|
||||
font-size: 9px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.step-copy {
|
||||
min-width: 0;
|
||||
}
|
||||
.step-btn.locked {
|
||||
opacity: 0.7;
|
||||
cursor: pointer;
|
||||
}
|
||||
.step-btn[data-state='confirmed'] .avatar {
|
||||
border-color: var(--ok);
|
||||
color: var(--ok);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user