diff --git a/prototypes/hel-646-flow-desk/app.css b/prototypes/hel-646-flow-desk/app.css new file mode 100644 index 00000000..c7956a08 --- /dev/null +++ b/prototypes/hel-646-flow-desk/app.css @@ -0,0 +1,542 @@ +/* HEL-646 流水台原型 · 设计 Token 统一在 :root,组件只引用变量 */ +:root { + --bg: #121211; + --bg-2: #191917; + --bg-3: #22221f; + --bg-4: #2b2b27; + --line: #2c2c28; + --line-2: #3b3b35; + --text: #f2f1ec; + --text-2: #b6b4ab; + --text-3: #7f7d75; + --accent: #c9f36b; + --accent-ink: #182200; + --accent-soft: rgba(201, 243, 107, 0.12); + --run: #86adff; + --run-soft: rgba(134, 173, 255, 0.14); + --err: #ff8070; + --err-soft: rgba(255, 128, 112, 0.12); + --warn: #f3c55a; + --warn-soft: rgba(243, 197, 90, 0.12); + + --r-sm: 6px; + --r-md: 10px; + --r-lg: 14px; + --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line-2); + + --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; + --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, monospace; + + --ease-out: cubic-bezier(0.23, 1, 0.32, 1); + --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); + --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); + --d-press: 120ms; + --d-state: 150ms; + --d-pop: 180ms; + --d-enter: 220ms; + --d-drawer: 280ms; +} + +:root[data-reduce="1"] { + --d-press: 0ms; + --d-pop: 120ms; + --d-enter: 120ms; + --d-drawer: 120ms; +} + +* { box-sizing: border-box; } +html, body { height: 100%; margin: 0; } +body { + background: var(--bg); + color: var(--text); + font: 13px/1.55 var(--font); + -webkit-font-smoothing: antialiased; + overflow: hidden; +} +button, input, textarea, select { font: inherit; color: inherit; } +button { cursor: pointer; background: none; border: 0; padding: 0; } +:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); } +.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; } +.muted { color: var(--text-3); } +.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } + +/* ---------- 壳层 ---------- */ +.app { display: grid; grid-template-columns: 60px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; } +.rail { + display: flex; flex-direction: column; align-items: center; gap: 4px; + padding: 12px 0; border-right: 1px solid var(--line); background: var(--bg); +} +.rail .logo { + width: 34px; height: 34px; border-radius: 9px; margin-bottom: 14px; + display: grid; place-items: center; font-weight: 700; font-size: 16px; + background: var(--accent); color: var(--accent-ink); +} +.rail .spacer { flex: 1; } +.rail-btn { + position: relative; width: 44px; height: 44px; border-radius: var(--r-md); + display: grid; place-items: center; color: var(--text-3); + transition: color var(--d-state) ease, background-color var(--d-state) ease; +} +.rail-btn svg { width: 20px; height: 20px; } +.rail-btn[aria-current="page"] { color: var(--text); background: var(--bg-3); } +.rail-btn[aria-current="page"]::before { + content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; + border-radius: 0 3px 3px 0; background: var(--accent); +} +.rail-btn .tip { + position: absolute; left: 52px; white-space: nowrap; pointer-events: none; + background: var(--bg-4); color: var(--text); padding: 4px 8px; border-radius: var(--r-sm); + font-size: 12px; opacity: 0; transform: translateX(-4px); + transition: opacity var(--d-pop) var(--ease-out), transform var(--d-pop) var(--ease-out); + z-index: 30; +} +@media (hover: hover) and (pointer: fine) { + .rail-btn:hover { color: var(--text); background: var(--bg-2); } + .rail-btn:hover .tip { opacity: 1; transform: none; transition-delay: 350ms; } +} + +.main { display: grid; grid-template-rows: 52px minmax(0, 1fr); min-width: 0; } +.topbar { + display: flex; align-items: center; gap: 10px; padding: 0 16px; + border-bottom: 1px solid var(--line); +} +.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; } +.crumb h1 { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; } +.capsule { + display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; + border: 1px solid var(--line-2); border-radius: 999px; color: var(--text-2); white-space: nowrap; + transition: border-color var(--d-state) ease, color var(--d-state) ease; +} +.capsule .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); } +.capsule .dot.run { background: var(--run); } +.capsule .dot.err { background: var(--err); } +@media (hover: hover) and (pointer: fine) { + .capsule:hover { border-color: var(--text-3); color: var(--text); } +} +.topbar .grow { flex: 1; } +.kbd { + font: 11px var(--mono); color: var(--text-3); border: 1px solid var(--line-2); + border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; line-height: 16px; +} +.search-btn { min-width: 240px; justify-content: space-between; } + +/* 通用按钮 */ +.btn { + display: inline-flex; align-items: center; justify-content: center; gap: 6px; + height: 32px; padding: 0 12px; border-radius: var(--r-md); + border: 1px solid var(--line-2); color: var(--text); background: var(--bg-2); + transition: transform var(--d-press) var(--ease-out), background-color var(--d-state) ease, border-color var(--d-state) ease, opacity var(--d-state) ease; + white-space: nowrap; +} +.btn svg { width: 15px; height: 15px; } +.btn:active:not(:disabled) { transform: scale(0.97); } +.btn:disabled { opacity: 0.45; cursor: not-allowed; } +.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; } +.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); } +.btn.danger { color: var(--err); } +.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; border-radius: var(--r-sm); } +@media (hover: hover) and (pointer: fine) { + .btn:hover:not(:disabled) { border-color: var(--text-3); } + .btn.primary:hover:not(:disabled) { background: #d6f88a; } + .btn.ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--text); } +} + +.tag { + display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; + border-radius: 999px; font-size: 11px; color: var(--text-2); background: var(--bg-3); + white-space: nowrap; +} +.tag.accent { color: var(--accent); background: var(--accent-soft); } +.tag.run { color: var(--run); background: var(--run-soft); } +.tag.err { color: var(--err); background: var(--err-soft); } +.tag.warn { color: var(--warn); background: var(--warn-soft); } + +/* ---------- 视图切换 ---------- */ +.view { display: none; min-height: 0; } +.view.on { display: grid; } + +/* ---------- 生成台 ---------- */ +.desk { grid-template-columns: minmax(0, 1fr) 420px; grid-template-rows: minmax(0, 1fr); min-height: 0; } +.desk-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; } +.context-bar { + display: none; align-items: center; gap: 10px; margin: 10px 20px 0; padding: 8px 12px; + border-radius: var(--r-md); background: var(--run-soft); color: var(--text); font-size: 12px; +} +.context-bar.on { display: flex; } +.context-bar b { color: var(--run); font-weight: 600; } +.filters { display: flex; align-items: center; gap: 6px; padding: 10px 20px; border-bottom: 1px solid var(--line); } +.seg { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); } +.seg button { + height: 26px; padding: 0 10px; border-radius: 8px; color: var(--text-3); + transition: background-color var(--d-state) ease, color var(--d-state) ease; +} +.seg button[aria-pressed="true"] { background: var(--bg-4); color: var(--text); } +.filters .count { margin-left: auto; color: var(--text-3); font-size: 12px; } + +.feed { flex: 1; overflow-y: auto; padding: 16px 20px 8px; scroll-behavior: smooth; } +:root[data-reduce="1"] .feed { scroll-behavior: auto; } +.feed-day { color: var(--text-3); font-size: 12px; margin: 10px 0 8px; display: flex; align-items: center; gap: 8px; } +.feed-day::after { content: ""; flex: 1; height: 1px; background: var(--line); } + +.take { + position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; + padding: 12px 14px; margin-bottom: 8px; border-radius: var(--r-lg); + border: 1px solid transparent; background: var(--bg-2); cursor: pointer; + transition: border-color var(--d-state) ease, background-color var(--d-state) ease, opacity var(--d-enter) var(--ease-out), transform var(--d-enter) var(--ease-out); +} +@starting-style { .take.new { opacity: 0; transform: translateY(8px); } } +:root[data-reduce="1"] .take.new { transform: none; } +.take.selected { border-color: var(--accent); background: var(--bg-3); } +.take.leaving { opacity: 0; transform: translateX(-12px); pointer-events: none; } +@media (hover: hover) and (pointer: fine) { + .take:hover:not(.selected) { border-color: var(--line-2); } +} +.take-head { display: flex; align-items: center; gap: 8px; min-width: 0; } +.take-head .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.take-head .meta { color: var(--text-3); font-size: 12px; white-space: nowrap; } +.take-prompt { + grid-column: 1; color: var(--text-2); font-size: 12.5px; + display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; +} +.take-inputs { display: flex; gap: 4px; align-items: center; } +.take-inputs .mini { width: 26px; height: 26px; border-radius: 5px; background-size: cover; background-position: center; border: 1px solid var(--line-2); } +.take-inputs .more { font-size: 11px; color: var(--text-3); padding-left: 2px; } +.take-out { grid-column: 2; grid-row: 1 / span 3; align-self: start; } +.thumb { + position: relative; width: 150px; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; + background: var(--bg-4) center / cover no-repeat; +} +.thumb.portrait { width: 96px; aspect-ratio: 3 / 4; } +.thumb.fresh { transition: opacity var(--d-state) ease; } +@starting-style { .thumb.fresh { opacity: 0; } } +.thumb .badge { + position: absolute; right: 6px; bottom: 6px; font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; + background: rgba(0, 0, 0, 0.6); color: #fff; +} +.thumb .play { + position: absolute; left: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 50%; + display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); +} +.thumb .play svg { width: 10px; height: 10px; fill: #fff; } +.thumb.missing, .thumb.pending { + display: grid; place-items: center; text-align: center; font-size: 11px; color: var(--text-3); + border: 1px dashed var(--line-2); background: var(--bg-2); padding: 6px; +} +.thumb.pending { border-style: solid; overflow: hidden; } +.thumb.pending::after { + content: ""; position: absolute; inset: 0; + background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%); + animation: sheen 1.4s linear infinite; +} +@keyframes sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } } +:root[data-reduce="1"] .thumb.pending::after { animation: none; } + +.take-state { grid-column: 1; display: flex; align-items: center; gap: 8px; font-size: 12px; min-height: 22px; } +.take-state .txt { color: var(--text-2); } +.take-state .err-txt { color: var(--err); } +.bar { position: relative; flex: 0 0 140px; height: 4px; border-radius: 4px; background: var(--bg-4); overflow: hidden; } +.bar i { + position: absolute; inset: 0; background: var(--run); transform-origin: left; + transform: scaleX(var(--p, 0)); transition: transform 400ms linear; +} +.take-actions { display: flex; gap: 4px; margin-left: auto; opacity: 0; transition: opacity var(--d-state) ease; } +.take:focus-within .take-actions, .take.selected .take-actions { opacity: 1; } +@media (hover: hover) and (pointer: fine) { .take:hover .take-actions { opacity: 1; } } +@media (hover: none) { .take-actions { opacity: 1; } } +.err-detail { grid-column: 1 / -1; display: none; margin: 0; padding: 8px 10px 8px 26px; border-radius: var(--r-md); background: var(--err-soft); color: var(--text-2); font-size: 12px; } +.take.open .err-detail { display: block; } +.err-detail li { margin: 2px 0; } + +/* ---------- 输入台 ---------- */ +.composer-wrap { padding: 8px 20px 16px; } +.composer { + border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg-2); + transition: border-color var(--d-state) ease; +} +.composer:focus-within { border-color: var(--text-3); } +.slots { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 0; } +.slots:empty { display: none; } +.slot-group { display: flex; flex-direction: column; gap: 6px; } +.slot-label { font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; } +.slot-label .req { color: var(--warn); } +.slot-row { display: flex; gap: 6px; flex-wrap: wrap; } +.tile { + position: relative; width: 58px; height: 58px; border-radius: var(--r-md); + background: var(--bg-3) center / cover no-repeat; border: 1px solid var(--line-2); + display: grid; place-items: center; color: var(--text-3); + transition: border-color var(--d-state) ease, transform var(--d-press) var(--ease-out), opacity var(--d-enter) var(--ease-out); +} +@starting-style { .tile.filled { opacity: 0; transform: scale(0.94); } } +.tile.add { border-style: dashed; } +.tile.add svg { width: 18px; height: 18px; } +.tile.add:active { transform: scale(0.97); } +.tile.drag { border-color: var(--accent); background-color: var(--accent-soft); color: var(--accent); } +.tile.bad { border-color: var(--err); } +.tile.need { border-color: var(--warn); } +.tile .x { + position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; + background: var(--bg-4); border: 1px solid var(--line-2); display: grid; place-items: center; opacity: 0; + transition: opacity var(--d-state) ease; +} +.tile .x svg { width: 9px; height: 9px; } +.tile:focus-within .x { opacity: 1; } +@media (hover: hover) and (pointer: fine) { .tile:hover .x { opacity: 1; } .tile.add:hover { border-color: var(--text-3); color: var(--text); } } +@media (hover: none) { .tile .x { opacity: 1; } } +.tile .ring { position: absolute; inset: 0; border-radius: inherit; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; font-size: 11px; color: #fff; } +.tile .idx { position: absolute; left: 3px; top: 2px; font: 10px var(--mono); color: #fff; text-shadow: 0 1px 2px #000; } +.slot-hint { font-size: 11px; color: var(--text-3); } +.slot-hint.err { color: var(--err); } + +.prompt { + display: block; width: 100%; resize: none; border: 0; outline: 0; background: transparent; + padding: 12px 14px 6px; min-height: 52px; max-height: 180px; line-height: 1.6; +} +.prompt::placeholder { color: var(--text-3); } +.composer-foot { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px 8px; flex-wrap: wrap; } +.chip { + display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; + background: var(--bg-3); color: var(--text-2); font-size: 12px; white-space: nowrap; max-width: 280px; + transition: background-color var(--d-state) ease, color var(--d-state) ease, transform var(--d-press) var(--ease-out); +} +.chip:active { transform: scale(0.97); } +.chip .lbl { overflow: hidden; text-overflow: ellipsis; } +.chip svg { width: 14px; height: 14px; flex: none; } +.chip.wf { color: var(--text); background: var(--bg-4); font-weight: 500; } +.chip.warn { color: var(--warn); } +.chip.err { color: var(--err); } +.chip.changed { color: var(--accent); } +@media (hover: hover) and (pointer: fine) { .chip:hover { background: var(--bg-4); color: var(--text); } } +.submit-group { margin-left: auto; display: flex; align-items: center; gap: 10px; } +.why { font-size: 12px; color: var(--warn); white-space: nowrap; text-decoration: underline dotted; text-underline-offset: 3px; } +.why.err { color: var(--err); } +.gen-btn { height: 34px; padding: 0 16px; border-radius: 999px; } + +/* ---------- 右侧检视区 ---------- */ +.inspector { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); } +.insp-tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; } +.insp-body { flex: 1; overflow-y: auto; padding: 14px; } +.stage { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #000; aspect-ratio: 16 / 9; } +.stage.portrait { aspect-ratio: 3 / 4; max-height: 480px; margin: 0 auto; } +.stage > * { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity var(--d-state) ease; } +.stage .fade-out { opacity: 0; } +.stage-empty { display: grid; place-items: center; color: var(--text-3); font-size: 12px; background: var(--bg-2); } +.stage-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 12px 0; font-size: 12px; color: var(--text-3); } +.stage-meta b { color: var(--text-2); font-weight: 500; } +.stage-actions { display: flex; flex-wrap: wrap; gap: 6px; } +.section-title { font-size: 12px; color: var(--text-3); margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; } +.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 12px; } +.kv dt { color: var(--text-3); } +.kv dd { margin: 0; color: var(--text-2); word-break: break-all; } + +/* 参数表单(按工作流 JSON 生成) */ +.field { display: grid; gap: 6px; margin-bottom: 12px; } +.field label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); } +.field label .orig { color: var(--text-3); font-family: var(--mono); font-size: 11px; } +.input { + height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg-2); + padding: 0 10px; outline: 0; width: 100%; + transition: border-color var(--d-state) ease; +} +.input:focus { border-color: var(--text-3); } +.input.changed { border-color: rgba(201, 243, 107, 0.5); } +textarea.input { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; } +.fold { border-top: 1px solid var(--line); margin-top: 6px; } +.fold > summary { + list-style: none; cursor: pointer; padding: 10px 0; display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; +} +.fold > summary::-webkit-details-marker { display: none; } +.fold > summary svg { width: 12px; height: 12px; transition: transform var(--d-pop) var(--ease-out); } +.fold[open] > summary svg { transform: rotate(90deg); } +.note { font-size: 12px; color: var(--text-3); padding: 8px 10px; border-radius: var(--r-md); background: var(--bg-2); margin-bottom: 12px; } +.note.warn { color: var(--warn); background: var(--warn-soft); } +.note.err { color: var(--err); background: var(--err-soft); } +.note ul { margin: 6px 0 0; padding-left: 18px; } + +/* ---------- 浮层:工作流面板 ---------- */ +.pop { + position: fixed; z-index: 50; width: 520px; max-height: min(560px, 70vh); display: flex; flex-direction: column; + border-radius: var(--r-lg); background: var(--bg-2); box-shadow: var(--shadow-float); + opacity: 0; transform: scale(0.96); pointer-events: none; transform-origin: var(--origin, bottom left); + transition: opacity var(--d-pop) var(--ease-out), transform var(--d-pop) var(--ease-out); +} +.pop.on { opacity: 1; transform: none; pointer-events: auto; } +.pop.instant { transition: none; } +:root[data-reduce="1"] .pop { transform: none; } +.pop-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); } +.pop-search input { flex: 1; background: transparent; border: 0; outline: 0; font-size: 14px; } +.pop-list { overflow-y: auto; padding: 6px; } +.pop-group { font-size: 11px; color: var(--text-3); padding: 10px 10px 4px; display: flex; gap: 6px; } +.wf-row { + display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; + padding: 8px 10px; border-radius: var(--r-md); +} +.wf-row[aria-selected="true"] { background: var(--bg-4); } +.wf-row .n { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.wf-row .s { grid-column: 1; display: flex; gap: 4px; flex-wrap: wrap; } +.wf-row .r { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 11px; text-align: right; } +.wf-row.off .n { color: var(--text-3); } +.pop-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; gap: 6px; align-items: center; } +.pop-foot .hint { margin-left: auto; font-size: 11px; color: var(--text-3); display: flex; gap: 6px; align-items: center; } + +.menu { width: 260px; } +.menu .pop-list button { display: flex; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); gap: 8px; align-items: center; } +.menu .pop-list button:hover, .menu .pop-list button[aria-selected="true"] { background: var(--bg-4); } + +/* ---------- 抽屉:导入工作流 ---------- */ +.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); opacity: 0; pointer-events: none; transition: opacity var(--d-drawer) ease; z-index: 60; } +.scrim.on { opacity: 1; pointer-events: auto; } +.drawer { + position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 100vw; z-index: 61; + background: var(--bg-2); border-left: 1px solid var(--line-2); display: flex; flex-direction: column; + transform: translateX(100%); transition: transform var(--d-drawer) var(--ease-drawer); +} +.drawer.on { transform: none; } +:root[data-reduce="1"] .drawer { transform: none; opacity: 0; pointer-events: none; transition: opacity var(--d-drawer) ease; } +:root[data-reduce="1"] .drawer.on { opacity: 1; pointer-events: auto; } +.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); } +.drawer-head h2 { font-size: 15px; margin: 0; flex: 1; } +.drawer-body { flex: 1; overflow-y: auto; padding: 16px; } +.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); } +.drop { + border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: 14px; display: grid; gap: 10px; + transition: border-color var(--d-state) ease, background-color var(--d-state) ease; +} +.drop.drag { border-color: var(--accent); background: var(--accent-soft); } +.drop textarea { width: 100%; min-height: 110px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px; font: 12px/1.5 var(--mono); color: var(--text-2); resize: vertical; outline: 0; } +.checks { display: grid; gap: 8px; margin-top: 14px; } +.check { display: grid; grid-template-columns: 22px 1fr; gap: 2px 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); } +.check .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-4); color: var(--text-3); font-size: 11px; transition: background-color var(--d-state) ease, color var(--d-state) ease; } +.check.ok .ic { background: var(--accent-soft); color: var(--accent); } +.check.bad .ic { background: var(--err-soft); color: var(--err); } +.check.run .ic { background: var(--run-soft); color: var(--run); } +.check .t { font-weight: 500; } +.check .d { grid-column: 2; color: var(--text-3); font-size: 12px; } +.check .d ul { margin: 4px 0 0; padding-left: 16px; } +.slot-map { display: grid; gap: 6px; margin-top: 8px; } +.slot-map div { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 6px 8px; border-radius: var(--r-sm); background: var(--bg-3); } +.usage-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; } +.usage-pick button { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); font-size: 12px; } +.usage-pick button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); } + +/* ---------- Toast ---------- */ +.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 80; display: grid; gap: 8px; pointer-events: none; max-width: 400px; } +.toast { + display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: var(--r-md); + background: var(--bg-4); box-shadow: var(--shadow-float); pointer-events: auto; min-width: 280px; + transition: opacity var(--d-enter) var(--ease-out), transform var(--d-enter) var(--ease-out); +} +@starting-style { .toast { opacity: 0; transform: translateY(100%); } } +.toast.out { opacity: 0; transform: translateY(100%); } +:root[data-reduce="1"] .toast, :root[data-reduce="1"] .toast.out { transform: none; } +.toast .grow { flex: 1; } +.toast button { color: var(--accent); font-weight: 600; } + +/* ---------- 任务托盘 ---------- */ +.tray { width: 340px; } +.tray-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-md); width: 100%; text-align: left; } +.tray-row:hover { background: var(--bg-3); } +.tray-row .t { width: 36px; height: 36px; border-radius: 6px; background: var(--bg-4) center / cover; } +.tray-row .n { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.tray-row .m { font-size: 11px; color: var(--text-3); } + +/* ---------- 项目 / 创作流程 ---------- */ +.page { overflow-y: auto; padding: 24px 28px 40px; align-content: start; gap: 18px; } +.hero { + display: grid; grid-template-columns: 300px 1fr; gap: 20px; padding: 16px; border-radius: var(--r-lg); background: var(--bg-2); border: 1px solid var(--line); +} +.hero .cover { aspect-ratio: 16 / 9; border-radius: var(--r-md); background: var(--bg-4) center / cover; } +.hero h2 { margin: 2px 0 6px; font-size: 20px; } +.hero p { margin: 0 0 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } +.track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0 14px; } +.track button { text-align: left; padding: 8px 10px; border-radius: var(--r-md); background: var(--bg-3); font-size: 12px; color: var(--text-2); transition: background-color var(--d-state) ease; } +.track button .k { display: block; font-size: 11px; color: var(--text-3); } +.track button.done .k { color: var(--accent); } +.track button.cur { background: var(--bg-4); color: var(--text); box-shadow: inset 0 -2px 0 var(--warn); } +.track button.cur .k { color: var(--warn); } +.track button[aria-current="step"] { outline: 1px solid var(--text-3); } +.proj-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; } +.proj { display: grid; gap: 6px; padding: 12px; border-radius: var(--r-lg); background: var(--bg-2); border: 1px solid var(--line); text-align: left; transition: border-color var(--d-state) ease; } +@media (hover: hover) and (pointer: fine) { .proj:hover { border-color: var(--line-2); } } +.proj .pips { display: flex; gap: 3px; } +.proj .pips i { flex: 1; height: 3px; border-radius: 3px; background: var(--bg-4); } +.proj .pips i.d { background: var(--accent); } +.proj .pips i.c { background: var(--warn); } +.row-actions { display: flex; gap: 8px; flex-wrap: wrap; } +.shot { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--bg-2); border: 1px solid var(--line); align-items: start; } +.shot .no { font: 600 13px var(--mono); color: var(--warn); } +.shot .p { color: var(--text-2); font-size: 12.5px; } +.shot .en { margin-top: 6px; font: 11.5px/1.5 var(--mono); color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } +.placeholder { place-items: center; text-align: center; color: var(--text-3); padding: 40px; } +.placeholder h2 { color: var(--text); font-size: 16px; } + +/* 原型标记 */ +.proto-flag { font-size: 11px; color: var(--text-3); border: 1px dashed var(--line-2); padding: 2px 8px; border-radius: 999px; white-space: nowrap; } +.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; } +.switch input { accent-color: var(--accent); } + +/* 底部标签栏(窄屏) */ +.tabbar { display: none; } +.mobile-only { display: none; } + +/* ---------- 中屏:检视区改为右侧浮层 ---------- */ +@media (max-width: 1180px) { + .desk { grid-template-columns: minmax(0, 1fr); } + .inspector { + position: fixed; top: 52px; right: 0; bottom: 0; width: 400px; z-index: 40; box-shadow: var(--shadow-float); + transform: translateX(100%); transition: transform var(--d-drawer) var(--ease-drawer); + } + .inspector.on { transform: none; } + :root[data-reduce="1"] .inspector { transform: none; opacity: 0; pointer-events: none; transition: opacity var(--d-drawer) ease; } + :root[data-reduce="1"] .inspector.on { opacity: 1; pointer-events: auto; } + .insp-close { display: inline-flex !important; } + .search-btn { min-width: 0; } + .search-btn .lbl { display: none; } +} + +/* ---------- 窄屏:底部标签栏 + 输入台底部抽屉 ---------- */ +@media (max-width: 760px) { + .app { grid-template-columns: 1fr; } + .rail { display: none; } + .main { grid-template-rows: 48px minmax(0, 1fr) 56px; } + .topbar { padding: 0 12px; gap: 8px; } + .topbar .hide-sm { display: none; } + .mobile-only { display: inline-flex; } + .tabbar { + display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--bg); + } + .tabbar button { display: grid; place-items: center; gap: 2px; font-size: 11px; color: var(--text-3); padding-top: 6px; } + .tabbar button svg { width: 20px; height: 20px; } + .tabbar button[aria-current="page"] { color: var(--accent); } + .filters { padding: 8px 12px; overflow-x: auto; } + .filters .count { display: none; } + .feed { padding: 12px 12px 4px; } + .take { grid-template-columns: minmax(0, 1fr) auto; padding: 10px; } + .take-head { flex-wrap: wrap; row-gap: 2px; } + .take-out { grid-row: 1 / span 2; } + .take-state { grid-column: 1 / -1; flex-wrap: wrap; } + .take-state .txt, .take-state .err-txt { white-space: nowrap; } + .take-actions { margin-left: auto; } + .toasts { left: 12px; right: 12px; bottom: 124px; max-width: none; } + .thumb { width: 108px; } + .thumb.portrait { width: 72px; } + .bar { flex-basis: 80px; } + .composer-wrap { padding: 6px 10px 10px; } + .composer:not(.expanded) .slots, .composer:not(.expanded) .opt-chip { display: none; } + .composer:not(.expanded) .prompt { min-height: 40px; max-height: 40px; padding: 10px 12px 2px; white-space: nowrap; overflow: hidden; } + .composer.expanded { position: fixed; left: 0; right: 0; bottom: 56px; z-index: 45; border-radius: 16px 16px 0 0; border-bottom: 0; box-shadow: var(--shadow-float); } + .chip { max-width: 170px; } + .inspector { top: 0; width: 100vw; bottom: 0; z-index: 70; } + .pop { left: 0 !important; right: 0; top: auto !important; bottom: 0 !important; width: 100vw; border-radius: 16px 16px 0 0; max-height: 78vh; --origin: bottom center; } + .drawer { width: 100vw; } + .page { padding: 16px 12px 24px; } + .hero { grid-template-columns: 1fr; } + .track { grid-template-columns: repeat(5, minmax(64px, 1fr)); overflow-x: auto; } + .shot { grid-template-columns: 30px 1fr; } + .shot .btn { grid-column: 2; justify-self: start; } +} + +@media (prefers-reduced-motion: reduce) { + :root { --d-press: 0ms; --d-pop: 120ms; --d-enter: 120ms; --d-drawer: 120ms; } + .take.new, .tile.filled { transform: none !important; } + .thumb.pending::after { animation: none; } +} diff --git a/prototypes/hel-646-flow-desk/app.js b/prototypes/hel-646-flow-desk/app.js new file mode 100644 index 00000000..822755d0 --- /dev/null +++ b/prototypes/hel-646-flow-desk/app.js @@ -0,0 +1,1222 @@ +/* HEL-646 流水台原型:纯前端模拟,数据取自测试站 192.168.200.15:8080 的真实工作流与任务记录。 */ +(() => { + 'use strict'; + + const $ = (s, r = document) => r.querySelector(s); + const $$ = (s, r = document) => Array.from(r.querySelectorAll(s)); + const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); + const root = document.documentElement; + const reduceQuery = matchMedia('(prefers-reduced-motion: reduce)'); + const reduced = () => reduceQuery.matches || root.dataset.reduce === '1'; + const icon = (id) => ``; + + const USAGE = { + text2image: '文生图', image2image: '图生图', text2video: '文生视频', image2video: '图生视频', ref2video: '参考图生视频', + }; + const USAGE_ORDER = ['text2image', 'image2image', 'text2video', 'image2video', 'ref2video']; + const CONNS = [ + { id: 'local', name: '本机 ComfyUI-4080', url: 'http://192.168.200.12:8188', ok: true, ms: 22 }, + { id: 'hy', name: '恒源云', url: 'http://127.0.0.1:6008', ok: false, err: '连接被拒绝:目标端口没有服务在监听' }, + ]; + + const H3_PARAMS = [ + { key: 'aspect', label: '画面比例', kind: 'select', orig: '16:9', options: ['16:9', '9:16', '1:1', '4:3', '21:9'], common: true }, + { key: 'duration', label: '时长(秒)', kind: 'select', orig: '10', options: ['3', '5', '8', '10'], common: true, unit: '秒' }, + { key: 'seed', label: '随机种子', kind: 'seed', orig: '42', common: true }, + { key: 'megapixels', label: '总像素(百万)', kind: 'number', orig: '0.7', step: 0.1 }, + { key: 'steps', label: '采样步数', kind: 'number', orig: '4' }, + { key: 'denoise', label: '降噪强度', kind: 'number', orig: '1', step: 0.05 }, + ]; + const QWEN_T2I = [ + { key: 'aspect', label: '画面比例', kind: 'select', orig: '1:1', options: ['1:1', '3:4', '4:3', '16:9', '9:16'], common: true }, + { key: 'seed', label: '随机种子', kind: 'seed', orig: '593103825222985', common: true }, + { key: 'negative', label: '反向提示词', kind: 'textarea', orig: '' }, + { key: 'megapixels', label: '总像素(百万)', kind: 'number', orig: '1', step: 0.1 }, + { key: 'batch', label: '批次数量', kind: 'number', orig: '1' }, + { key: 'steps', label: '采样步数', kind: 'number', orig: '25' }, + { key: 'cfg', label: 'CFG', kind: 'number', orig: '1', step: 0.1 }, + { key: 'denoise', label: '降噪强度', kind: 'number', orig: '1', step: 0.05 }, + ]; + + const workflows = [ + { id: 13, name: 'H3 参考生视频·参考图(05 用户提供)', usage: 'ref2video', kind: 'video', conn: 'local', status: 'ok', statusText: '可用 · 近 3 次成功', + slots: [{ key: 'ref', label: '参考图', type: 'list', min: 1, max: 9 }], params: H3_PARAMS, + note: 'MiniMax H3 Ref2VA 官方限额:参考图最多 9 张;本工作流 JSON 只连了参考图,不显示参考视频 / 音频入口。', + defaultPrompt: '' }, + { id: 12, name: 'H3 图生视频·首帧(04 用户提供)', usage: 'image2video', kind: 'video', conn: 'local', status: 'ok', statusText: '可用 · 近 2 次成功', + slots: [{ key: 'first', label: '首帧图', type: 'single' }], params: H3_PARAMS, note: '首帧决定画面外观,提示词描述运动。' }, + { id: 11, name: 'Qwen Image 2.1 图片编辑(用户提供)', usage: 'image2image', kind: 'image', conn: 'local', status: 'error', statusText: '不可用 · 文件不完整', + slots: [{ key: 'image', label: '输入图', type: 'single' }], + params: [ + { key: 'resolution', label: '输出分辨率', kind: 'number', orig: '1024', common: true }, + { key: 'seed', label: '随机种子', kind: 'seed', orig: '278835418249884', common: true }, + { key: 'negative', label: '反向提示词', kind: 'textarea', orig: '模糊,低质量,文字乱码,变形' }, + { key: 'steps', label: '采样步数', kind: 'number', orig: '25' }, + { key: 'cfg', label: 'CFG', kind: 'number', orig: '1', step: 0.1 }, + { key: 'denoise', label: '降噪强度', kind: 'number', orig: '1', step: 0.05 }, + ], + errors: [ + '节点 1「Unet Loader (GGUF)」缺少节点类型(class_type),导出时 ComfyUI 未加载该自定义节点', + '节点 9「Patch Sage Attention KJ」缺少节点类型(class_type),导出时 ComfyUI 未加载该自定义节点', + '节点 6「K采样器」(KSampler)没有连接模型(model),模型加载链路在导出时丢失', + ] }, + { id: 10, name: 'qwen2.1', usage: 'text2image', kind: 'image', conn: 'local', status: 'ok', statusText: '可用 · 09-29 19:26 试运行通过', slots: [], params: QWEN_T2I }, + { id: 7, name: 'qwen-image-2.1', usage: 'text2image', kind: 'image', conn: null, status: 'idle', statusText: '未试运行 · 跟随默认连接', slots: [], params: QWEN_T2I }, + { id: 6, name: 'minimaxh3-文生图加速版', usage: 'text2video', kind: 'video', conn: null, status: 'idle', statusText: '未试运行 · 名称含“文生图”,实际判定为文生视频', slots: [], params: H3_PARAMS }, + { id: 5, name: 'MiniMax H3 文生视频(审核示例)', usage: 'text2video', kind: 'video', conn: null, status: 'idle', statusText: '未试运行', + slots: [], params: [ + { key: 'duration', label: 'Seconds', kind: 'select', orig: '10', options: ['5', '10'], common: true, unit: '秒' }, + { key: 'fps', label: 'fps', kind: 'number', orig: '24' }, + ] }, + { id: 4, name: 'Krea2 文生图(审核示例)', usage: 'text2image', kind: 'image', conn: null, status: 'warn', statusText: '上次失败 · 连接上缺 3 个模型', slots: [], params: [] }, + ]; + + const A = 'assets/'; + const G = [ + 'linear-gradient(135deg,#6a5cff,#ff7ac6)', 'linear-gradient(135deg,#ff9a3c,#ffd36e)', 'linear-gradient(135deg,#1f8f7a,#9be15d)', + 'linear-gradient(135deg,#2336a8,#5bc0ff)', 'linear-gradient(135deg,#8a2be2,#4b0082)', 'linear-gradient(135deg,#f25f5c,#247ba0)', + ]; + let seq = 100; + const takes = [ + { id: 16, wf: 6, scope: 'standalone', day: '昨天', time: '09-28 23:33', prompt: 'integrated_multimodal_description: a red paper lantern drifting slowly upward through light evening snow over a quiet canal, rippling water reflections', + inputs: [], params: { aspect: '16:9', duration: '3', seed: '42' }, status: 'done', elapsed: '2 分 10 秒', + out: { poster: A + 'v-t2v-16.jpg', src: A + 'v-t2v-16.mp4', w: 736, h: 416, dur: '0:02' } }, + { id: 21, wf: 6, scope: 'standalone', day: '昨天', time: '09-28 23:43', prompt: '(沿用工作流原值)地铁站台十镜头参考提示词', + inputs: [], params: { aspect: '16:9', duration: '5', seed: '42' }, status: 'done', elapsed: '2 分 42 秒', + out: { poster: A + 'v-t2v-21.jpg', src: A + 'v-t2v-21.mp4', w: 736, h: 416, dur: '0:05' } }, + { id: 31, wf: 4, scope: 'p1', source: '《雨夜便利店》创作流程', day: '今天', time: '09-29 08:48', prompt: 'Cinematic extreme wide static shot. Outside the modern 24-hour convenience store at night, heavy rain falls like a curtain…', + inputs: [], params: {}, status: 'failed', + error: { title: 'ComfyUI 拒绝执行:连接上缺 3 个模型文件', items: [ + '节点 149(CLIPLoader):ComfyUI 上没有「qwen3vl_4b_fp8_scaled.safetensors」', + '节点 148(UNETLoader):ComfyUI 上没有「Krea-2-Turbo.safetensors」', + '节点 152(LoraLoaderModelOnly):ComfyUI 上没有「krea2/Krea2-realism-V2.safetensors」', + ], raw: 'HTTP 400 · prompt_outputs_failed_validation' } }, + { id: 35, wf: 12, scope: 'standalone', day: '今天', time: '09-29 10:41', prompt: '镜头缓缓推进,画面中渐变色彩的微光流动', + inputs: [{ bg: G[3], name: 'test-a.png' }], params: { aspect: '16:9', duration: '3', seed: '42' }, status: 'done', elapsed: '49 秒', + out: { poster: A + 'v-i2v-35.jpg', src: A + 'v-i2v-35.mp4', w: 1152, h: 640, dur: '0:03' } }, + { id: 40, wf: 10, scope: 'standalone', day: '今天', time: '09-29 16:41', prompt: '一只戴墨镜的橘猫坐在电影院前排, 电影放映的光束打在毛上, 胶片感', + inputs: [], params: { aspect: '1:1', seed: '593103825222985' }, status: 'missing', elapsed: '14 秒', + out: { name: 'Qwen_image_2.1_00003.png', w: 1024, h: 1024 } }, + { id: 43, wf: 10, scope: 'standalone', day: '今天', time: '09-29 19:59', prompt: 'Greyscale fashion editorial portrait of an avant-garde woman tilted upwards in profile, captured with striking high-contrast chiaroscuro lighting. She wears oversized, thick-rimmed circular black sunglasses…', + inputs: [], params: { aspect: '3:4', seed: '593103825222985' }, status: 'done', elapsed: '13 秒', + out: { poster: A + 'i-t2i-43.jpg', src: A + 'i-t2i-43.jpg', w: 888, h: 1184, image: true } }, + { id: 44, wf: 13, scope: 'standalone', day: '今天', time: '09-29 20:00', prompt: '让图片中的人物动起来', + inputs: [{ bg: `url(${A}i-t2i-43.jpg)`, name: 'Qwen_image_2.1_00005.png' }], params: { aspect: '16:9', duration: '5', seed: '42', megapixels: '0.4' }, status: 'done', elapsed: '44 秒', + out: { poster: A + 'v-ref2v-44.jpg', src: A + 'v-ref2v-44.mp4', w: 864, h: 480, dur: '0:05' } }, + ]; + + const RESULT_FOR = { + ref2video: { poster: A + 'v-ref2v-44.jpg', src: A + 'v-ref2v-44.mp4', w: 864, h: 480, dur: '0:05' }, + image2video: { poster: A + 'v-i2v-35.jpg', src: A + 'v-i2v-35.mp4', w: 1152, h: 640, dur: '0:03' }, + text2video: { poster: A + 'v-t2v-16.jpg', src: A + 'v-t2v-16.mp4', w: 736, h: 416, dur: '0:02' }, + text2image: { poster: A + 'i-t2i-43.jpg', src: A + 'i-t2i-43.jpg', w: 888, h: 1184, image: true }, + image2image: { poster: A + 'i-t2i-43.jpg', src: A + 'i-t2i-43.jpg', w: 888, h: 1184, image: true }, + }; + + const state = { + wfId: 13, + connId: 'local', + slots: {}, + params: {}, + filter: 'all', + scope: 'all', + selected: 44, + context: null, + view: 'desk', + }; + + const wfById = (id) => workflows.find((w) => w.id === id); + const curWf = () => wfById(state.wfId); + const connById = (id) => CONNS.find((c) => c.id === id); + + /* ---------------- Toast ---------------- */ + function toast(text, opts = {}) { + const el = document.createElement('div'); + el.className = 'toast'; + el.innerHTML = `${text}${opts.action ? `` : ''}`; + $('#toasts').appendChild(el); + let done = false; + const close = () => { + if (done) return; + done = true; + el.classList.add('out'); + setTimeout(() => el.remove(), reduced() ? 130 : 240); + }; + if (opts.action) el.querySelector('button').addEventListener('click', () => { opts.onAction?.(); close(); }); + setTimeout(() => { opts.onTimeout?.(); close(); }, opts.duration || 3200); + return close; + } + + /* ---------------- 浮层管理 ---------------- */ + const layers = []; + function openLayer(el, { anchor, instant, origin, onClose, trigger } = {}) { + closeLayer(el, true); + el.classList.toggle('instant', !!instant || false); + if (anchor && innerWidth > 760) { + const r = anchor.getBoundingClientRect(); + const w = el.offsetWidth || 520; + let left = Math.min(r.left, innerWidth - w - 12); + if (origin === 'top right') left = Math.max(12, r.right - w); + el.style.left = left + 'px'; + if (origin && origin.startsWith('top')) { el.style.top = r.bottom + 8 + 'px'; el.style.bottom = 'auto'; } + else { el.style.top = 'auto'; el.style.bottom = innerHeight - r.top + 8 + 'px'; } + el.style.setProperty('--origin', origin || 'bottom left'); + } else if (innerWidth > 760) { + el.style.left = `calc(50% - ${(el.offsetWidth || 520) / 2}px)`; + el.style.top = '12vh'; + el.style.bottom = 'auto'; + el.style.setProperty('--origin', 'top center'); + } + el.classList.add('on'); + layers.push({ el, onClose, trigger: trigger || document.activeElement }); + } + function closeLayer(el, silent) { + const i = layers.findIndex((l) => l.el === el); + if (i < 0) return; + const [l] = layers.splice(i, 1); + el.classList.remove('on'); + l.onClose?.(); + if (!silent && l.trigger && document.contains(l.trigger)) l.trigger.focus({ preventScroll: true }); + } + function closeTop() { + const l = layers[layers.length - 1]; + if (l) { closeLayer(l.el); return true; } + return false; + } + document.addEventListener('pointerdown', (e) => { + for (const l of [...layers]) { + if (l.el.classList.contains('drawer')) continue; + if (l.el.id === 'inspector' && e.target.closest('#feed, .pop, .toast')) continue; + if (!l.el.contains(e.target) && !(l.trigger && l.trigger.contains?.(e.target))) closeLayer(l.el, true); + } + }); + + /* ---------------- 工作流选择面板 ---------------- */ + let wfActive = 0; + let wfRows = []; + let wfFromCmd = false; + function renderWfList() { + const q = $('#wf-search').value.trim().toLowerCase(); + const match = (w) => !q || w.name.toLowerCase().includes(q) || USAGE[w.usage].includes(q) || slotSummary(w).includes(q); + let html = ''; + wfRows = []; + for (const u of USAGE_ORDER) { + const list = workflows.filter((w) => w.usage === u && match(w)); + if (!list.length) continue; + html += `
${USAGE[u]} ${list.length}
`; + for (const w of list) { + const idx = wfRows.length; + wfRows.push({ type: 'wf', id: w.id }); + const conn = w.conn ? connById(w.conn).name : '跟随默认连接'; + const statusCls = w.status === 'ok' ? 'accent' : w.status === 'error' ? 'err' : w.status === 'warn' ? 'warn' : ''; + html += ``; + } + } + if (wfFromCmd) { + const jumps = [ + { label: '跳转 · 雨夜便利店 / 镜头脚本(待确认)', go: () => nav('flow') }, + { label: '跳转 · 项目总览', go: () => nav('projects') }, + ].filter((j) => !q || j.label.includes(q)); + if (jumps.length) { + html += '
跳转
'; + for (const j of jumps) { + const idx = wfRows.length; + wfRows.push({ type: 'jump', go: j.go }); + html += ``; + } + } + } + if (!wfRows.length) html = `
没有匹配“${esc(q)}”的工作流。可以。
`; + $('#wf-list').innerHTML = html; + wfActive = Math.max(0, Math.min(wfActive, wfRows.length - 1)); + paintWfActive(); + } + function paintWfActive() { + $$('#wf-list .wf-row').forEach((b) => b.setAttribute('aria-selected', String(+b.dataset.i === wfActive))); + $(`#wf-list .wf-row[data-i="${wfActive}"]`)?.scrollIntoView({ block: 'nearest' }); + } + function pickWfRow(i) { + const row = wfRows[i]; + if (!row) return; + closeLayer($('#wf-pop')); + if (row.type === 'jump') { row.go(); return; } + selectWorkflow(row.id); + } + function openWfPop(fromCmd) { + wfFromCmd = !!fromCmd; + $('#wf-search').value = ''; + renderWfList(); + wfActive = Math.max(0, wfRows.findIndex((r) => r.id === state.wfId)); + paintWfActive(); + openLayer($('#wf-pop'), fromCmd ? { instant: true, trigger: document.activeElement } : { anchor: $('#wf-chip'), origin: 'bottom left', trigger: $('#wf-chip') }); + setTimeout(() => $('#wf-search').focus(), 0); + } + $('#wf-chip').addEventListener('click', () => ($('#wf-pop').classList.contains('on') ? closeLayer($('#wf-pop')) : openWfPop(false))); + $('#wf-search').addEventListener('input', () => { wfActive = 0; renderWfList(); }); + $('#wf-search').addEventListener('keydown', (e) => { + if (e.key === 'ArrowDown') { wfActive = Math.min(wfRows.length - 1, wfActive + 1); paintWfActive(); e.preventDefault(); } + else if (e.key === 'ArrowUp') { wfActive = Math.max(0, wfActive - 1); paintWfActive(); e.preventDefault(); } + else if (e.key === 'Enter') { pickWfRow(wfActive); e.preventDefault(); } + }); + $('#wf-list').addEventListener('click', (e) => { + const b = e.target.closest('.wf-row'); + if (b) pickWfRow(+b.dataset.i); + if (e.target.closest('[data-act="import"]')) { closeLayer($('#wf-pop'), true); openImport(); } + }); + $('#wf-list').addEventListener('pointermove', (e) => { + const b = e.target.closest('.wf-row'); + if (b && +b.dataset.i !== wfActive) { wfActive = +b.dataset.i; paintWfActive(); } + }); + $('#import-open').addEventListener('click', () => { closeLayer($('#wf-pop'), true); openImport(); }); + + function slotSummary(w) { + if (!w.slots.length) return '仅提示词'; + return w.slots.map((s) => (s.type === 'list' ? `${s.label} ${s.min}–${s.max} 张` : `${s.label} ×1`)).join(' · '); + } + + function selectWorkflow(id, { keepPrompt = true } = {}) { + const prev = curWf(); + const w = wfById(id); + state.wfId = id; + // 已上传的图片跨工作流保留(按新槽位上限截断);参数回到新工作流原值 + const nextSlots = {}; + for (const s of w.slots) { + const carry = state.slots[s.key] || (prev.slots[0] ? state.slots[prev.slots[0].key] : null) || []; + nextSlots[s.key] = carry.slice(0, s.type === 'list' ? s.max : 1); + } + state.slots = nextSlots; + state.params = {}; + if (!keepPrompt) $('#prompt').value = w.defaultPrompt || ''; + if (w.conn) state.connId = w.conn; + renderComposer(); + renderParams(); + if (prev.id !== id) toast(`已切换到「${esc(w.name)}」· ${esc(slotSummary(w))}`, { duration: 2000 }); + } + + /* ---------------- 输入台 ---------------- */ + function renderComposer() { + const w = curWf(); + $('#wf-chip-label').textContent = w.name; + $('#wf-chip').classList.toggle('err', w.status === 'error'); + renderSlots(); + renderCommonChips(); + validate(); + } + + function renderSlots() { + const w = curWf(); + const box = $('#slots'); + box.innerHTML = w.slots.map((s) => { + const items = state.slots[s.key] || []; + const max = s.type === 'list' ? s.max : 1; + const tiles = items.map((it, i) => ` +
+ ${s.type === 'list' ? `${i + 1}` : ''} + ${it.uploading ? '上传中' : ''} + +
`).join(''); + const add = items.length < max ? `` : ''; + const hint = s.type === 'list' ? `${s.min}–${s.max} 张 · 已选 ${items.length}${items.length >= max ? ' · 已达上限' : ''}` : '必填 · 1 张'; + return `
+
${esc(s.label)}*${hint} + ${takes.some((t) => t.status === 'done' && t.out?.image) ? `` : ''} +
+
${tiles}${add}
+
+
`; + }).join(''); + } + + let pendingSlot = null; + $('#slots').addEventListener('click', (e) => { + const add = e.target.closest('[data-add]'); + const rm = e.target.closest('[data-remove]'); + const fr = e.target.closest('[data-from-results]'); + if (add) { pendingSlot = add.dataset.add; $('#file-input').multiple = curWf().slots.find((s) => s.key === pendingSlot).type === 'list'; $('#file-input').click(); } + if (rm) { + const [k, i] = rm.dataset.remove.split(':'); + state.slots[k].splice(+i, 1); + renderSlots(); validate(); + } + if (fr) openFromResults(fr); + }); + $('#file-input').addEventListener('change', (e) => { addFiles(pendingSlot, e.target.files); e.target.value = ''; }); + + function slotHint(key, text, isErr) { + const el = $(`[data-hint="${key}"]`); + if (!el) return; + el.textContent = text; + el.classList.toggle('err', !!isErr); + clearTimeout(el._t); + el._t = setTimeout(() => { el.textContent = ''; }, 2600); + } + + function addFiles(key, files) { + const w = curWf(); + const slot = w.slots.find((s) => s.key === key) || w.slots[0]; + if (!slot) { toast('当前工作流没有图片输入槽,不能添加图片。换一个图生图 / 图生视频 / 参考图生视频工作流再试。'); return; } + key = slot.key; + const max = slot.type === 'list' ? slot.max : 1; + state.slots[key] = state.slots[key] || []; + let rejected = 0; let overflow = 0; + for (const f of Array.from(files)) { + if (!/^image\/(png|jpeg|webp)$/.test(f.type)) { rejected++; continue; } + if (f.size > 20 * 1024 * 1024) { rejected++; continue; } + if (slot.type === 'single') state.slots[key] = []; + if (state.slots[key].length >= max) { overflow++; continue; } + const it = { bg: `url(${URL.createObjectURL(f)})`, name: f.name, uploading: true }; + state.slots[key].push(it); + setTimeout(() => { it.uploading = false; renderSlots(); validate(); }, 450 + Math.random() * 500); + } + renderSlots(); validate(); + if (rejected) slotHint(key, `有 ${rejected} 个文件未添加:仅支持 PNG / JPG / WebP,单张不超过 20MB`, true); + else if (overflow) slotHint(key, `已达上限 ${max} 张,多出的 ${overflow} 张未添加`, true); + } + + function openFromResults(anchor) { + const key = anchor.dataset.fromResults; + const imgs = takes.filter((t) => t.status === 'done' && t.out?.image); + $('#menu-list').innerHTML = imgs.map((t) => ``).join(''); + openLayer($('#menu-pop'), { anchor, origin: 'bottom left', trigger: anchor }); + $('#menu-list').onclick = (e) => { + const b = e.target.closest('[data-pick]'); + if (!b) return; + const t = takes.find((x) => x.id === +b.dataset.pick); + pushInput(key, { bg: `url(${t.out.poster})`, name: `结果 #${t.id}` }); + closeLayer($('#menu-pop')); + }; + } + function pushInput(key, it) { + const slot = curWf().slots.find((s) => s.key === key); + if (!slot) return false; + state.slots[key] = state.slots[key] || []; + if (slot.type === 'single') state.slots[key] = []; + if (state.slots[key].length >= slot.max) { slotHint(key, `已达上限 ${slot.max} 张`, true); return false; } + state.slots[key].push(it); + renderSlots(); validate(); + return true; + } + + // 拖入:整个输入台都是投放区,落在哪个槽就进哪个槽 + const composer = $('#composer'); + composer.addEventListener('dragover', (e) => { + if (!curWf().slots.length) return; + e.preventDefault(); + const tile = e.target.closest('.tile.add') || $('#slots .tile.add'); + $$('#slots .tile.add').forEach((t) => t.classList.toggle('drag', t === tile)); + }); + composer.addEventListener('dragleave', (e) => { if (!composer.contains(e.relatedTarget)) $$('#slots .tile.drag').forEach((t) => t.classList.remove('drag')); }); + composer.addEventListener('drop', (e) => { + e.preventDefault(); + const tile = e.target.closest('[data-add],[data-slot]'); + $$('#slots .tile.drag').forEach((t) => t.classList.remove('drag')); + addFiles(tile ? tile.dataset.add || tile.dataset.slot : curWf().slots[0]?.key, e.dataTransfer.files); + }); + + function paramValue(p) { return state.params[p.key] ?? p.orig; } + function changedCount() { return curWf().params.filter((p) => state.params[p.key] !== undefined && state.params[p.key] !== p.orig).length; } + + function renderCommonChips() { + const w = curWf(); + const conn = connById(state.connId); + const chips = w.params.filter((p) => p.common).map((p) => { + const v = paramValue(p); + const changed = state.params[p.key] !== undefined && v !== p.orig; + if (p.kind === 'seed') return ``; + return ``; + }); + chips.unshift(``); + $('#common-chips').innerHTML = chips.join(''); + const n = changedCount(); + $('#params-chip-label').textContent = n ? `参数 · 已改 ${n} 项` : '全部参数'; + $('#params-chip').classList.toggle('changed', n > 0); + } + + $('#common-chips').addEventListener('click', (e) => { + const b = e.target.closest('[data-chip]'); + if (!b) return; + const key = b.dataset.chip; + if (key === 'conn') { + $('#menu-list').innerHTML = CONNS.map((c) => ``).join(''); + openLayer($('#menu-pop'), { anchor: b, origin: 'bottom left', trigger: b }); + $('#menu-list').onclick = (ev) => { + const x = ev.target.closest('[data-conn]'); + if (!x) return; + state.connId = x.dataset.conn; + closeLayer($('#menu-pop')); + renderCommonChips(); validate(); + }; + return; + } + const p = curWf().params.find((q) => q.key === key); + if (p.kind === 'seed') { state.params.seed = String(Math.floor(Math.random() * 1e9)); renderCommonChips(); renderParams(); return; } + $('#menu-list').innerHTML = p.options.map((o) => ``).join(''); + openLayer($('#menu-pop'), { anchor: b, origin: 'bottom left', trigger: b }); + $('#menu-list').onclick = (ev) => { + const x = ev.target.closest('[data-opt]'); + if (!x) return; + state.params[key] = x.dataset.opt; + closeLayer($('#menu-pop')); + renderCommonChips(); renderParams(); + }; + }); + + function validate() { + const w = curWf(); + const why = $('#why'); + const conn = connById(state.connId); + let msg = ''; let err = false; let act = null; + const missing = w.slots.filter((s) => (state.slots[s.key] || []).length < (s.type === 'list' ? s.min : 1)); + const uploading = w.slots.some((s) => (state.slots[s.key] || []).some((it) => it.uploading)); + if (w.status === 'error') { msg = '工作流不可用 · 查看原因'; err = true; act = () => showParamsTab(); } + else if (!conn.ok) { msg = `「${conn.name}」连不上 · 换连接`; err = true; act = () => $('[data-chip="conn"]')?.click(); } + else if (missing.length) { msg = `还缺:${missing.map((s) => s.label).join('、')}`; act = () => flashSlot(missing[0].key); } + else if (uploading) { msg = '素材上传中…'; } + else if (!$('#prompt').value.trim()) { msg = '还缺:提示词'; act = () => $('#prompt').focus(); } + why.hidden = !msg; + why.textContent = msg; + why.classList.toggle('err', err); + why.onclick = act; + $('#gen-btn').disabled = !!msg; + } + function flashSlot(key) { + const t = $(`[data-add="${key}"]`) || $(`[data-slot="${key}"]`); + if (!t) return; + t.classList.add('need'); + t.focus(); + setTimeout(() => t.classList.remove('need'), 1200); + if (innerWidth <= 760) composer.classList.add('expanded'); + } + $('#prompt').addEventListener('input', () => { + const el = $('#prompt'); + el.style.height = 'auto'; + el.style.height = Math.min(el.scrollHeight, 180) + 'px'; + validate(); + }); + $('#prompt').addEventListener('focus', () => { if (innerWidth <= 760) composer.classList.add('expanded'); }); + document.addEventListener('pointerdown', (e) => { + if (innerWidth <= 760 && composer.classList.contains('expanded') && !composer.contains(e.target) && !e.target.closest('.pop')) composer.classList.remove('expanded'); + }); + + /* ---------------- 提交与进度 ---------------- */ + function submit() { + if ($('#gen-btn').disabled) { $('#why').click(); return; } + const w = curWf(); + const conn = connById(state.connId); + const inputs = w.slots.flatMap((s) => (state.slots[s.key] || []).map((it) => ({ bg: it.bg, name: it.name }))); + const params = {}; + for (const p of w.params) params[p.key] = paramValue(p); + const t = { + id: ++seq, wf: w.id, scope: state.context ? 'p1' : 'standalone', source: state.context ? '《雨夜便利店》镜头 S1' : null, + day: '今天', time: nowStr(), prompt: $('#prompt').value.trim(), inputs, params, status: 'queued', progress: 0, phase: '提交中', isNew: true, demo: true, + conn: conn.name, + }; + takes.push(t); + state.selected = t.id; + if (state.filter === 'failed' || (state.filter !== 'all' && state.filter !== w.kind)) setFilter('all'); + renderFeed({ scrollToEnd: true }); + renderPreview(false); + updateTray(); + composer.classList.remove('expanded'); + runSim(t); + } + function nowStr() { + const d = new Date(); + const p = (n) => String(n).padStart(2, '0'); + return `09-29 ${p(d.getHours())}:${p(d.getMinutes())}`; + } + function runSim(t) { + const w = wfById(t.wf); + const steps = w.kind === 'video' + ? [[t.inputs.length ? '上传素材' : '提交到 ComfyUI', 0.05], ['排队中 · 第 1 位', 0.08], ['采样 1/4', 0.25], ['采样 2/4', 0.42], ['采样 3/4', 0.6], ['采样 4/4', 0.76], ['解码视频', 0.9], ['保存结果', 0.97]] + : [['提交到 ComfyUI', 0.05], ['排队中 · 第 1 位', 0.1], ['采样 8/25', 0.35], ['采样 17/25', 0.65], ['采样 25/25', 0.88], ['保存结果', 0.97]]; + let i = 0; + const started = Date.now(); + const tick = () => { + if (!takes.includes(t)) return; + if (i < steps.length) { + const [phase, p] = steps[i++]; + t.status = i <= 2 ? 'queued' : 'running'; + t.phase = phase; t.progress = p; + t.elapsedMs = Date.now() - started; + patchTake(t); + if (state.selected === t.id) renderPreview(false); + setTimeout(tick, 650 + Math.random() * 300); + } else { + t.status = 'done'; + t.justDone = true; + t.progress = 1; + t.out = { ...RESULT_FOR[w.usage] }; + t.elapsed = `${Math.round((Date.now() - started) / 1000)} 秒(演示加速)`; + patchTake(t, true); + updateTray(); + if (state.selected === t.id) renderPreview(true); + if (!isTakeVisible(t)) toast(`「${esc(w.name)}」已完成`, { action: '查看', onAction: () => selectTake(t.id, { scroll: true }) }); + } + updateTray(); + }; + setTimeout(tick, 250); + } + function isTakeVisible(t) { + const el = $(`.take[data-id="${t.id}"]`); + if (!el || state.view !== 'desk') return false; + const r = el.getBoundingClientRect(); const f = $('#feed').getBoundingClientRect(); + return r.bottom > f.top && r.top < f.bottom; + } + $('#gen-btn').addEventListener('click', submit); + + /* ---------------- 记录流 ---------------- */ + function visibleTakes() { + return takes.filter((t) => { + if (state.scope !== 'all' && t.scope !== state.scope) return false; + const w = wfById(t.wf); + if (state.filter === 'image') return w.kind === 'image'; + if (state.filter === 'video') return w.kind === 'video'; + if (state.filter === 'failed') return t.status === 'failed' || t.status === 'missing'; + return true; + }); + } + function takeHTML(t) { + const w = wfById(t.wf); + const sel = t.id === state.selected; + const src = t.source || (w.kind === 'video' ? '独立生视频' : '独立生图'); + const inputs = t.inputs.length + ? `
${t.inputs.slice(0, 4).map((i) => ``).join('')}${t.inputs.length > 4 ? `+${t.inputs.length - 4}` : ''}
` : ''; + let out = ''; + const portrait = t.out && t.out.h > t.out.w; + if (t.status === 'done') { + out = `
${t.out.image ? '' : `${icon('play')}${t.out.dur}`}
`; + } else if (t.status === 'missing') { + out = '
结果文件已不在
服务器上
'; + } else if (t.status === 'failed') { + out = '
未生成
'; + } else { + out = `
${esc(t.phase)}
`; + } + let st = ''; + if (t.status === 'done') st = `完成用时 ${esc(t.elapsed)}`; + else if (t.status === 'queued' || t.status === 'running') st = `${t.status === 'queued' ? '排队' : '生成中'}${esc(t.phase)} · ${Math.round(t.progress * 100)}%`; + else if (t.status === 'failed') st = `失败${esc(t.error.title)}`; + else if (t.status === 'missing') st = '文件缺失记录还在,产物已被清理或移动'; + const actions = t.status === 'done' + ? `` + : t.status === 'failed' ? '' + : t.status === 'missing' ? '' : ''; + return `
+
${esc(w.name)}${USAGE[w.usage]}${esc(src)} · ${esc(t.time.slice(6))}
+
${esc(t.prompt || '(使用工作流原提示词)')}
+ ${inputs ? `
${inputs}
` : ''} +
${st}
${actions}
+
${out}
+ ${t.status === 'failed' ? `` : ''} +
`; + } + function renderFeed({ scrollToEnd } = {}) { + const list = visibleTakes(); + let html = ''; let day = ''; + for (const t of list) { + if (t.day !== day) { day = t.day; html += `
${day}
`; } + html += takeHTML(t); + } + if (!list.length) html = `
${state.filter === 'failed' ? '没有失败或缺失的记录。' : '这里还没有记录。选好工作流、写下提示词,按 Ctrl + Enter 生成。'}
`; + const feed = $('#feed'); + feed.innerHTML = html; + takes.forEach((t) => { t.isNew = false; }); + const running = takes.filter((t) => t.status === 'queued' || t.status === 'running').length; + $('#feed-count').textContent = `${list.length} 条记录${running ? ` · ${running} 个进行中` : ''}`; + if (scrollToEnd) requestAnimationFrame(() => { feed.scrollTop = feed.scrollHeight; }); + } + function patchTake(t, finished) { + const el = $(`.take[data-id="${t.id}"]`); + if (!el) return; + if (!finished && el.querySelector('.bar')) { + el.querySelector('.bar i').style.setProperty('--p', t.progress); + el.querySelector('.take-state .txt').textContent = `${t.phase} · ${Math.round(t.progress * 100)}%`; + el.querySelector('.take-state .tag').textContent = t.status === 'queued' ? '排队' : '生成中'; + el.querySelector('.thumb.pending').textContent = t.phase; + return; + } + const tmp = document.createElement('div'); + tmp.innerHTML = takeHTML(t); + t.justDone = false; + el.replaceWith(tmp.firstElementChild); + const running = takes.filter((x) => x.status === 'queued' || x.status === 'running').length; + $('#feed-count').textContent = `${visibleTakes().length} 条记录${running ? ` · ${running} 个进行中` : ''}`; + } + + $('#feed').addEventListener('click', (e) => { + const el = e.target.closest('.take'); + if (!el) return; + const t = takes.find((x) => x.id === +el.dataset.id); + const act = e.target.closest('[data-act]')?.dataset.act; + if (act === 'detail') { t.open = !t.open; patchTake(t, true); return; } + if (act === 'retry') { retry(t); return; } + if (act === 'delete') { removeTake(t); return; } + if (act === 'reuse') { reuse(t); return; } + if (act === 'download') { toast(`原型不连后端:正式版直接下载 ${t.out.image ? '图片' : 'MP4'} 原文件`); return; } + if (act === 'cancel') { takes.splice(takes.indexOf(t), 1); renderFeed(); updateTray(); toast('已取消该任务,ComfyUI 队列中的对应任务同步中断'); return; } + selectTake(t.id, { fromPointer: true }); + }); + + function selectTake(id, { fromPointer, scroll } = {}) { + if (!takes.some((t) => t.id === id)) return; + if (state.view !== 'desk') nav('desk'); + const prev = state.selected; + state.selected = id; + $$('.take').forEach((el) => { const on = +el.dataset.id === id; el.classList.toggle('selected', on); el.setAttribute('aria-selected', String(on)); }); + const el = $(`.take[data-id="${id}"]`); + if (el && (scroll || !fromPointer)) el.scrollIntoView({ block: 'nearest', behavior: reduced() || !scroll ? 'auto' : 'smooth' }); + if (prev !== id) renderPreview(!!fromPointer); + showPreviewTab(); + if (innerWidth <= 1180 && fromPointer) openInspector(); + } + + function moveSelection(delta) { + const list = visibleTakes(); + if (!list.length) return; + let i = list.findIndex((t) => t.id === state.selected); + i = i < 0 ? list.length - 1 : Math.max(0, Math.min(list.length - 1, i + delta)); + selectTake(list[i].id, { fromPointer: false }); + } + + function removeTake(t) { + const el = $(`.take[data-id="${t.id}"]`); + const idx = takes.indexOf(t); + const w = wfById(t.wf); + const vis = visibleTakes(); + const vi = vis.indexOf(t); + const neighbor = vis[vi + 1] || vis[vi - 1]; + el?.classList.add('leaving'); + setTimeout(() => { + takes.splice(takes.indexOf(t), 1); + if (state.selected === t.id) state.selected = neighbor ? neighbor.id : null; + renderFeed(); renderPreview(false); updateTray(); + }, reduced() ? 0 : 200); + let undone = false; + toast(`已删除「${esc(w.name)}」这条记录${t.out && !t.out.name ? '及其结果文件' : ''}`, { + action: '撤销', duration: 5000, + onAction: () => { undone = true; takes.splice(Math.min(idx, takes.length), 0, t); t.isNew = true; state.selected = t.id; renderFeed(); renderPreview(false); updateTray(); }, + onTimeout: () => { if (!undone) { /* 正式版:此时才调用 DELETE 接口 */ } }, + }); + } + function retry(t) { + const w = wfById(t.wf); + if (w.status === 'warn') { + toast('连接上仍缺 3 个模型文件,重试会再次被 ComfyUI 拒绝。先到「ComfyUI 连接」安装后点「重新检查」。', { action: '去连接页', onAction: () => nav('connections'), duration: 5200 }); + return; + } + reuse(t); submit(); + } + function reuse(t) { + const w = wfById(t.wf); + if (w.id !== state.wfId) selectWorkflow(w.id); + $('#prompt').value = t.prompt; + state.params = { ...t.params }; + for (const s of w.slots) state.slots[s.key] = t.inputs.slice(0, s.type === 'list' ? s.max : 1).map((i) => ({ ...i })); + renderComposer(); renderParams(); + $('#prompt').dispatchEvent(new Event('input')); + $('#prompt').focus(); + toast('已把这条记录的工作流、素材与参数放回输入台,可改完再生成'); + } + + /* ---------------- 检视区 ---------------- */ + function renderPreview(crossfade) { + const box = $('#insp-preview'); + const t = takes.find((x) => x.id === state.selected); + if (!t) { box.innerHTML = '
选择左侧一条记录查看结果
'; return; } + const w = wfById(t.wf); + const portrait = t.out && t.out.h > t.out.w; + const oldStage = box.querySelector('.stage'); + let media; + if (t.status === 'done') media = t.out.image ? `` : ``; + else if (t.status === 'missing') media = `
结果文件「${esc(t.out.name)}」已不在服务器上
可用相同参数重做,或移除这条记录
`; + else if (t.status === 'failed') media = `
${esc(t.error.title)}
`; + else media = `
${esc(t.phase)} · ${Math.round(t.progress * 100)}%
完成后自动显示在这里
`; + const meta = [ + t.out && t.status === 'done' ? `${t.out.w}×${t.out.h}` : '', + t.params.seed ? `种子 ${esc(t.params.seed)}` : '', + t.params.duration ? `时长 ${esc(t.params.duration)} 秒` : '', + t.elapsed ? `用时 ${esc(t.elapsed)}` : '', + `${esc(t.conn || '本机 ComfyUI-4080')}`, + t.demo && t.status === 'done' ? '演示产物 · 取自测试站历史结果,非本次真实生成' : '', + ].join(''); + const canSend = t.status === 'done' && t.out.image; + const actions = t.status === 'done' + ? `${canSend ? '' : ''}` + : t.status === 'failed' ? '' + : t.status === 'missing' ? '' : ''; + const html = ` +
${media}
+
${meta}
+
${actions}
+
输入
+ ${t.inputs.length ? `
${t.inputs.map((i) => ``).join('')}
` : ''} +
${esc(t.prompt || '(使用工作流原提示词)')}
+
工作流
+
名称
${esc(w.name)}
用途
${USAGE[w.usage]}
来源
${esc(t.source || (w.kind === 'video' ? '独立生视频' : '独立生图'))} · ${esc(t.time)}
+ ${Object.entries(t.params).filter(([k]) => !['seed', 'duration'].includes(k)).map(([k, v]) => `
${esc((w.params.find((p) => p.key === k) || { label: k }).label)}
${esc(v)}
`).join('')}
`; + const oldMedia = crossfade && oldStage && !reduced() ? Array.from(oldStage.children).map((c) => c.cloneNode(true)) : null; + box.innerHTML = html; + const newStage = box.querySelector('.stage'); + // 点选切换:旧画面叠在上层 150ms 淡出,新画面已在下层就位;键盘切换不做动画 + if (oldMedia && newStage.className === oldStage.className) { + const wrap = document.createElement('div'); + wrap.style.cssText = `position:absolute;inset:0;z-index:3;pointer-events:none;background:#000;transition:opacity var(--d-state) ease`; + oldMedia.forEach((c) => { if (c.tagName === 'VIDEO') c.removeAttribute('controls'); wrap.appendChild(c); }); + newStage.appendChild(wrap); + requestAnimationFrame(() => requestAnimationFrame(() => { wrap.style.opacity = '0'; })); + setTimeout(() => wrap.remove(), 200); + } + } + $('#insp-preview').addEventListener('click', (e) => { + const b = e.target.closest('[data-p]'); + if (!b) return; + const t = takes.find((x) => x.id === state.selected); + const act = b.dataset.p; + if (act === 'reuse') reuse(t); + if (act === 'retry') retry(t); + if (act === 'delete') removeTake(t); + if (act === 'download') toast(`原型不连后端:正式版直接下载 ${t.out.image ? '图片' : 'MP4'} 原文件`); + if (act === 'send') { + const slot = curWf().slots[0]; + if (!slot) { toast('当前工作流没有图片输入槽。切到图生视频或参考图生视频工作流后再送入。', { action: '选工作流', onAction: () => openWfPop(false) }); return; } + if (pushInput(slot.key, { bg: `url(${t.out.poster})`, name: `结果 #${t.id}` })) toast(`已送入「${slot.label}」`); + } + if (innerWidth <= 1180 && ['reuse', 'send', 'retry'].includes(act)) closeInspector(); + }); + + function showPreviewTab() { + $$('.insp-tabs [data-tab]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.tab === 'preview'))); + $('#insp-preview').hidden = false; $('#insp-params').hidden = true; + $('#insp-hint').textContent = '↑ ↓ 切换 · 空格播放'; + } + function showParamsTab() { + $$('.insp-tabs [data-tab]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.tab === 'params'))); + $('#insp-preview').hidden = true; $('#insp-params').hidden = false; + $('#insp-hint').textContent = '按工作流 JSON 生成'; + if (innerWidth <= 1180) openInspector(); + } + $('.insp-tabs').addEventListener('click', (e) => { + const b = e.target.closest('[data-tab]'); + if (b) (b.dataset.tab === 'preview' ? showPreviewTab : showParamsTab)(); + }); + $('#params-chip').addEventListener('click', showParamsTab); + function openInspector() { if (innerWidth <= 1180 && !$('#inspector').classList.contains('on')) { $('#inspector').classList.add('on'); layers.push({ el: $('#inspector'), onClose: () => $('#inspector').classList.remove('on') }); } } + function closeInspector() { closeLayer($('#inspector'), true); $('#inspector').classList.remove('on'); } + $('#insp-close').addEventListener('click', closeInspector); + + function renderParams() { + const w = curWf(); + const conn = w.conn ? connById(w.conn).name : `跟随默认连接(本次用 ${connById(state.connId).name})`; + const field = (p) => { + const v = paramValue(p); + const changed = state.params[p.key] !== undefined && v !== p.orig; + let input; + if (p.kind === 'select') input = ``; + else if (p.kind === 'textarea') input = ``; + else input = ``; + return `
${input}
`; + }; + const common = w.params.filter((p) => p.common); + const adv = w.params.filter((p) => !p.common); + $('#insp-params').innerHTML = ` +
${esc(w.name)}
+
${USAGE[w.usage]}${esc(slotSummary(w))}${esc(conn)}
+ ${w.errors ? `
该工作流文件不完整,ComfyUI 无法执行,已禁止生成
请在已安装对应自定义节点的 ComfyUI 中重新导出 API 格式 JSON,再替换导入。
` : ''} + ${w.note ? `
${esc(w.note)}
` : ''} + ${w.status === 'warn' ? '
上次运行时连接上缺 3 个模型文件;装好后在「ComfyUI 连接」点「重新检查」。
' : ''} + ${w.params.length ? '' : '
此工作流只暴露提示词,没有其他可调参数。
'} + ${common.map(field).join('')} + ${adv.length ? `
${icon('right')}高级参数 ${adv.length} 项 · 不改就沿用工作流原值${adv.map(field).join('')}
` : ''} + ${changedCount() ? '' : ''}`; + } + $('#insp-params').addEventListener('input', (e) => { + const f = e.target.closest('[data-f]'); + if (!f) return; + state.params[f.dataset.f] = f.value; + f.classList.toggle('changed', f.value !== curWf().params.find((p) => p.key === f.dataset.f).orig); + renderCommonChips(); + }); + $('#insp-params').addEventListener('change', () => renderParams()); + $('#insp-params').addEventListener('click', (e) => { + if (e.target.closest('[data-reset]')) { state.params = {}; renderParams(); renderCommonChips(); } + if (e.target.closest('[data-reimport]')) openImport('B'); + }); + + /* ---------------- 筛选 / 范围 ---------------- */ + function setFilter(f) { + state.filter = f; + $$('.filters [data-filter]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.filter === f))); + renderFeed({ scrollToEnd: true }); + } + $('.filters').addEventListener('click', (e) => { const b = e.target.closest('[data-filter]'); if (b) setFilter(b.dataset.filter); }); + const SCOPES = [['all', '全部来源'], ['standalone', '独立创作'], ['p1', '雨夜便利店']]; + $('#scope-btn').addEventListener('click', () => { + $('#menu-list').innerHTML = SCOPES.map(([k, l]) => ``).join(''); + openLayer($('#menu-pop'), { anchor: $('#scope-btn'), origin: 'top left', trigger: $('#scope-btn') }); + $('#menu-list').onclick = (e) => { + const b = e.target.closest('[data-scope]'); + if (!b) return; + setScope(b.dataset.scope); + closeLayer($('#menu-pop')); + }; + }); + function setScope(s) { + state.scope = s; + $('#scope-label').textContent = SCOPES.find(([k]) => k === s)[1]; + renderFeed({ scrollToEnd: true }); + } + + /* ---------------- 任务托盘 ---------------- */ + function updateTray() { + const running = takes.filter((t) => t.status === 'queued' || t.status === 'running'); + $('#tray-dot').className = 'dot' + (running.length ? ' run' : ''); + $('#tray-label').textContent = running.length ? `${running.length} 个生成中` : '队列空闲'; + if ($('#tray-pop').classList.contains('on')) renderTray(); + } + function renderTray() { + const list = [...takes].reverse().slice(0, 6); + $('#tray-list').innerHTML = `
最近任务 · 点一下跳到对应记录
` + list.map((t) => { + const w = wfById(t.wf); + const st = t.status === 'done' ? '完成' : t.status === 'failed' ? '失败' : t.status === 'missing' ? '缺文件' : `${Math.round(t.progress * 100)}%`; + return ``; + }).join(''); + } + $('#tray-btn').addEventListener('click', () => { + if ($('#tray-pop').classList.contains('on')) { closeLayer($('#tray-pop')); return; } + renderTray(); + openLayer($('#tray-pop'), { anchor: $('#tray-btn'), origin: 'top right', trigger: $('#tray-btn') }); + }); + $('#tray-list').addEventListener('click', (e) => { + const b = e.target.closest('[data-go]'); + if (!b) return; + closeLayer($('#tray-pop'), true); + const t = takes.find((x) => x.id === +b.dataset.go); + if (!visibleTakes().includes(t)) { setFilter('all'); setScope('all'); } + selectTake(t.id, { scroll: true }); + }); + $('#conn-btn').addEventListener('click', () => nav('connections')); + + /* ---------------- 导入工作流抽屉 ---------------- */ + const SAMPLE_A = { + '1': { inputs: { value: 'Describe the motion from the first frame.' }, class_type: 'PrimitiveStringMultiline', _meta: { title: '正向提示词' } }, + '115': { inputs: { aspect_ratio: '16:9 (Widescreen)', megapixels: 0.7, multiple: 32 }, class_type: 'ResolutionSelector', _meta: { title: '分辨率' } }, + '124': { inputs: { steps: 4, denoise: 1, cfg: 1 }, class_type: 'KSampler', _meta: { title: 'K采样器' } }, + '129': { inputs: { noise_seed: 42 }, class_type: 'RandomNoise', _meta: { title: '随机种子' } }, + '133': { inputs: { value: 10 }, class_type: 'PrimitiveInt', _meta: { title: '时长(秒)' } }, + '901': { inputs: { image: 'first_frame.png' }, class_type: 'LoadImage', _meta: { title: '首帧 First Frame' } }, + '92': { inputs: { filename_prefix: 'h3_i2v', format: 'mp4' }, class_type: 'SaveVideo', _meta: { title: '保存视频' } }, + }; + const SAMPLE_B = { + '1': { inputs: { UNKNOWN: 'qwen-image-2.1-Q4_K_M.gguf' }, _meta: { title: 'Unet Loader (GGUF)' } }, + '2': { inputs: { clip_name: 'qwen3vl_8b_int8_convrot.safetensors', type: 'qwen_image' }, class_type: 'CLIPLoader', _meta: { title: '加载CLIP' } }, + '4': { inputs: { prompt: '参考角色五官,重新生成图片:高细节皮肤质感' }, class_type: 'TextEncodeQwenImageEdit', _meta: { title: '文本编码' } }, + '5': { inputs: { image: 'input.png' }, class_type: 'LoadImage', _meta: { title: '输入图' } }, + '6': { inputs: { seed: 278835418249884, steps: 25, cfg: 1, denoise: 1 }, class_type: 'KSampler', _meta: { title: 'K采样器' } }, + '8': { inputs: { filename_prefix: 'qwen_edit' }, class_type: 'SaveImage', _meta: { title: '保存图像' } }, + '9': { inputs: { sage_attention: 'auto' }, _meta: { title: 'Patch Sage Attention KJ' } }, + }; + + const imp = { name: '', conn: 'local', text: '', result: null, usage: null, test: 'none', trigger: null }; + + function openImport(sample) { + imp.name = ''; imp.text = ''; imp.result = null; imp.usage = null; imp.test = 'none'; + imp.trigger = document.activeElement; + renderImport(); + $('#scrim').classList.add('on'); + $('#drawer').classList.add('on'); + layers.push({ el: $('#drawer'), onClose: closeImportVisual, trigger: imp.trigger }); + if (sample) loadSample(sample); + setTimeout(() => $('#imp-name')?.focus(), 30); + } + function closeImportVisual() { $('#scrim').classList.remove('on'); $('#drawer').classList.remove('on'); } + $('#drawer-close').addEventListener('click', () => closeLayer($('#drawer'))); + $('#scrim').addEventListener('click', () => closeLayer($('#drawer'))); + + function loadSample(k) { + imp.text = JSON.stringify(k === 'A' ? SAMPLE_A : SAMPLE_B, null, 2); + imp.name = k === 'A' ? 'H3 图生视频·首帧(重新导出)' : 'Qwen Image 2.1 图片编辑(重新导出)'; + renderImport(); + analyze(); + } + + function renderImport() { + const r = imp.result; + $('#drawer-body').innerHTML = ` +
+
+
+
+
+ 把 ComfyUI「导出 (API)」得到的 JSON 拖到这里、粘贴,或选择文件 + +
+ +
+ 没有文件?试试: + + +
+
+
${r ? checksHTML(r) : ''}
`; + const canSave = r && r.ok && imp.usage; + $('#drawer-foot').innerHTML = ` + 原型内判定为前端简化版;正式版沿用后端 /api/workflows/analyze + ${r && !r.ok ? '' : ''} + `; + } + + function checksHTML(r) { + const c = (cls, ic, t, d) => `
${ic}${t}
${d}
`; + let html = ''; + html += r.errors.length + ? c('bad', '!', `第 1 步 · 文件结构:发现 ${r.errors.length} 个问题`, `请在已安装对应自定义节点的 ComfyUI 中重新导出 API 格式 JSON。`) + : c('ok', '✓', `第 1 步 · 文件结构正常`, `${r.nodeCount} 个节点 · API 格式`); + if (r.errors.length) return html + c('', '–', '第 2 步 · 用途与输入槽', '文件结构有问题,暂不判定') + c('', '–', '第 3 步 · 对照连接上的节点与模型', '跳过'); + const lowConf = r.confidence === 'low'; + html += c(lowConf ? 'run' : 'ok', lowConf ? '?' : '✓', lowConf ? '第 2 步 · 用途不确定,请确认' : `第 2 步 · 判定为「${USAGE[r.usage]}」`, + `${lowConf ? '检测到视频输出和图片输入,但无法确定图片是首帧还是参考图:' : '可手动更正:'} +
${USAGE_ORDER.map((u) => ``).join('')}
+
${r.slotsView.map((s) => `
${esc(s.label)}${esc(s.node)}
`).join('')} + ${r.outputs.map((o) => `
输出 · ${o.kind === 'video' ? '视频' : '图片'}${esc(o.node)}
`).join('')}
`); + const conn = connById(imp.conn); + if (!conn.ok) html += c('bad', '!', '第 3 步 · 连不上所选连接', `${esc(conn.name)}:${esc(conn.err)}。可以先保存,连接恢复后再「重新检查」。`); + else if (r.sample === 'A') html += c('ok', '✓', '第 3 步 · 连接上的节点与模型齐全', `${esc(conn.name)} · 自定义节点 7/7 已安装 · 模型文件已找到`); + else html += c('', 'i', '第 3 步 · 对照连接上的节点与模型', '原型未连接后端,正式版会查询该 ComfyUI 的 /object_info 并用中文列出缺失项'); + const testCls = imp.test === 'running' ? 'run' : imp.test === 'ok' ? 'ok' : ''; + const testTxt = imp.test === 'running' ? '试运行中 · 采样 2/4…' : imp.test === 'ok' ? '试运行通过 · 产出 1 个视频,可下载且类型正确' : '可选:真实提交一次,只有拿到可下载的正确类型产物才算通过'; + html += c(testCls, imp.test === 'ok' ? '✓' : '4', '第 4 步 · 试运行(可选)', `${testTxt}${imp.test === 'none' && conn.ok ? '
' : ''}`); + return html; + } + + function analyze() { + const text = imp.text.trim(); + if (!text) { imp.result = null; renderImport(); return; } + let json; + try { json = JSON.parse(text); } catch (e) { + imp.result = { ok: false, errors: [`不是合法的 JSON:${e.message}`] }; renderImport(); return; + } + if (Array.isArray(json.nodes) && json.links) { + imp.result = { ok: false, errors: ['这是 ComfyUI 界面格式(含 nodes / links),不是 API 格式。请在 ComfyUI 菜单里用「导出 (API)」重新导出。'] }; renderImport(); return; + } + const entries = Object.entries(json).filter(([, v]) => v && typeof v === 'object'); + const errors = []; + for (const [id, n] of entries) if (!n.class_type) errors.push(`节点 ${id}「${n._meta?.title || '未命名'}」缺少节点类型(class_type),导出时 ComfyUI 未加载该自定义节点`); + const outputs = []; const images = []; let prompt = null; const params = []; + for (const [id, n] of entries) { + const ct = n.class_type || ''; const title = n._meta?.title || ct; + if (/SaveVideo|VHS_VideoCombine|SaveWEBM|SaveAnimated|CreateVideo/i.test(ct)) outputs.push({ kind: 'video', node: `${id} · ${ct}` }); + else if (/SaveImage|PreviewImage/i.test(ct)) outputs.push({ kind: 'image', node: `${id} · ${ct}` }); + if (/^LoadImage/i.test(ct)) images.push({ id, title, role: /ref|参考/i.test(title) ? 'ref' : /first|start|首帧/i.test(title) ? 'first' : 'image' }); + if (!prompt && (/PrimitiveString|CLIPTextEncode|TextEncode/i.test(ct) || typeof n.inputs?.prompt === 'string')) prompt = { id, title }; + for (const k of Object.keys(n.inputs || {})) if (/^(seed|noise_seed|steps|cfg|denoise|aspect_ratio|megapixels|width|height|length|duration)$/.test(k)) params.push(k); + } + const hasVideo = outputs.some((o) => o.kind === 'video'); + if (!outputs.length && !errors.length) errors.push('没有找到输出节点(SaveImage / SaveVideo 等)。若使用了自定义输出节点,保存后需要手动指定输出。'); + let usage; let confidence = 'high'; + if (hasVideo) { + if (images.some((i) => i.role === 'ref')) usage = 'ref2video'; + else if (images.some((i) => i.role === 'first')) usage = 'image2video'; + else if (images.length) { usage = 'image2video'; confidence = 'low'; } + else usage = 'text2video'; + } else usage = images.length ? 'image2image' : 'text2image'; + const slotsView = []; + if (prompt) slotsView.push({ label: '提示词', node: `${prompt.id} · ${prompt.title}` }); + for (const i of images) slotsView.push({ label: i.role === 'ref' ? '参考图' : i.role === 'first' ? '首帧图' : '输入图', node: `${i.id} · ${i.title}` }); + if (params.length) slotsView.push({ label: `参数 ${new Set(params).size} 项`, node: [...new Set(params)].join(' / ') }); + imp.result = { ok: !errors.length, errors, nodeCount: entries.length, outputs, images, usage, confidence, slotsView, sample: text === JSON.stringify(SAMPLE_A, null, 2) ? 'A' : null }; + imp.usage = confidence === 'low' ? null : usage; + renderImportProgressively(); + } + function renderImportProgressively() { + renderImport(); + if (reduced()) return; + const items = $$('#imp-checks .check'); + items.forEach((el, i) => { el.style.opacity = '0'; el.style.transform = 'translateY(4px)'; el.style.transition = `opacity 200ms var(--ease-out) ${i * 60}ms, transform 200ms var(--ease-out) ${i * 60}ms`; }); + requestAnimationFrame(() => requestAnimationFrame(() => items.forEach((el) => { el.style.opacity = ''; el.style.transform = ''; }))); + } + + $('#drawer').addEventListener('input', (e) => { + if (e.target.id === 'imp-name') imp.name = e.target.value; + if (e.target.id === 'imp-text') { imp.text = e.target.value; clearTimeout(imp._t); imp._t = setTimeout(() => { const pos = e.target.selectionStart; analyze(); const ta = $('#imp-text'); ta.focus(); ta.setSelectionRange(pos, pos); }, 500); } + }); + $('#drawer').addEventListener('change', (e) => { if (e.target.id === 'imp-conn') { imp.conn = e.target.value; imp.test = 'none'; renderImport(); } }); + $('#drawer').addEventListener('click', (e) => { + const s = e.target.closest('[data-sample]'); + if (s) loadSample(s.dataset.sample); + if (e.target.closest('#imp-file')) $('#json-input').click(); + const u = e.target.closest('[data-usage]'); + if (u) { imp.usage = u.dataset.usage; renderImport(); } + const a = e.target.closest('[data-imp]')?.dataset.imp; + if (a === 'test') { + imp.test = 'running'; renderImport(); + setTimeout(() => { imp.test = 'ok'; renderImport(); }, 1800); + } + if (a === 'save' || a === 'save-bad') saveImport(a === 'save-bad'); + }); + $('#drawer').addEventListener('dragover', (e) => { if (e.target.closest('#imp-drop')) { e.preventDefault(); $('#imp-drop').classList.add('drag'); } }); + $('#drawer').addEventListener('dragleave', (e) => { if (!e.relatedTarget || !$('#imp-drop').contains(e.relatedTarget)) $('#imp-drop')?.classList.remove('drag'); }); + $('#drawer').addEventListener('drop', (e) => { + if (!e.target.closest('#imp-drop')) return; + e.preventDefault(); + const f = e.dataTransfer.files[0]; + if (f) readJsonFile(f); + }); + $('#json-input').addEventListener('change', (e) => { if (e.target.files[0]) readJsonFile(e.target.files[0]); e.target.value = ''; }); + function readJsonFile(f) { + f.text().then((t) => { imp.text = t; if (!imp.name) imp.name = f.name.replace(/\.json$/i, ''); renderImport(); analyze(); }); + } + + function saveImport(bad) { + const r = imp.result; + const name = imp.name.trim() || '未命名工作流'; + const usage = imp.usage || r.usage || 'text2image'; + const kind = usage.includes('video') ? 'video' : 'image'; + const slots = []; + if (usage === 'ref2video') slots.push({ key: 'ref', label: '参考图', type: 'list', min: 1, max: 9 }); + if (usage === 'image2video') slots.push({ key: 'first', label: '首帧图', type: 'single' }); + if (usage === 'image2image') slots.push({ key: 'image', label: '输入图', type: 'single' }); + const w = { + id: ++seq, name, usage, kind, conn: imp.conn, status: bad ? 'error' : imp.test === 'ok' ? 'ok' : 'idle', + statusText: bad ? '不可用 · 文件不完整' : imp.test === 'ok' ? '可用 · 刚刚试运行通过' : '未试运行', + slots, params: kind === 'video' ? H3_PARAMS : QWEN_T2I.slice(0, 2).concat(QWEN_T2I.slice(5)), errors: bad ? r.errors : null, + note: usage === 'ref2video' ? 'MiniMax H3 Ref2VA 官方限额:参考图最多 9 张。' : null, + }; + workflows.push(w); + closeLayer($('#drawer'), true); + closeImportVisual(); + selectWorkflow(w.id); + toast(bad ? `已保存「${esc(name)}」,标记为不可用,生成按钮保持禁用` : `已导入并选中「${esc(name)}」· 输入台已按 JSON 显示:${esc(slotSummary(w))}`, { duration: 4200 }); + } + + /* ---------------- 页面切换 ---------------- */ + const TITLES = { desk: '生成台', projects: '项目', flow: '雨夜便利店 · 创作流程', tasks: '生成台', agents: '智能体', connections: 'ComfyUI 连接', settings: '模型与设置', more: '更多' }; + function nav(v) { + if (v === 'tasks') { v = 'desk'; setScope('all'); toast('任务页并入生成台:「全部来源」即全部任务,右上角托盘随时看进度', { duration: 2800 }); } + state.view = v; + $$('.view').forEach((el) => el.classList.remove('on')); + const id = { desk: 'view-desk', projects: 'view-projects', flow: 'view-flow' }[v] || 'view-other'; + $('#' + id).classList.add('on'); + $$('[data-nav]').forEach((b) => b.toggleAttribute('aria-current', false)); + $$(`[data-nav="${v}"]`).forEach((b) => b.setAttribute('aria-current', 'page')); + $('#page-title').textContent = TITLES[v] || ''; + $('#scope-btn').style.display = v === 'desk' ? '' : 'none'; + if (v === 'projects') renderProjects(); + if (v === 'flow') renderFlow(); + if (id === 'view-other') renderOther(v); + if (v === 'desk') renderFeed({ scrollToEnd: false }); + } + $$('[data-nav]').forEach((b) => b.addEventListener('click', () => nav(b.dataset.nav))); + + const STAGES = [['剧本创作', 'done'], ['视觉设计', 'done'], ['分镜设计', 'done'], ['素材资产', 'done'], ['镜头脚本', 'cur']]; + const trackHTML = (cur) => `
${STAGES.map(([n, s], i) => ``).join('')}
`; + + function renderProjects() { + $('#view-projects').innerHTML = ` +

继续上次

+
+
+
暂无生成画面 · 场景 0 · 素材 0
+
镜头脚本 · 待确认

雨夜便利店

+

时长约 3 分钟(180 秒)· 现代深夜都市 · 24 小时便利店(内)、店外雨夜。刚下班的白领与浑身湿透的男人在暴雨夜的便利店相遇。

+ ${trackHTML(4)} +
+
+
+

全部项目 · 2

+
+ + +
`; + } + $('#view-projects').addEventListener('click', (e) => { + if (e.target.closest('[data-go-flow]')) nav('flow'); + else if (e.target.closest('[data-go-desk]')) { nav('desk'); setScope('p1'); } + else if (e.target.closest('[data-stage]')) nav('flow'); + else if (e.target.closest('[data-todo]')) toast('本原型只演示高频生成链路;该入口沿用现有功能'); + }); + + const SHOTS = [ + ['S1', '4s', '第一场店外暴雨,固定远景,暴雨如帘砸在便利店玻璃门,霓虹在积水里碎成冷蓝光,店内暖黄光从门缝透出。音效:暴雨声。', 'Cinematic extreme wide static shot. Outside the modern 24-hour convenience store at night, heavy rain falls like a curtain against the glass doors, neon signs smear into cold blue puddles, warm yellow interior light glows through the door seam…'], + ['S2', '4s', '女人推开玻璃门,湿透的黑大衣滴水,头发贴在脸上。店外冷雨与店内暖光在她身上交界。音效:门铃叮。', 'Cinematic full tracking shot. The 28-year-old woman with black long straight hair plastered to her face, soaked black coat dripping, pushes open the glass door into warm yellow interior light…'], + ['S3', '5s', '男人站在饮料柜前没动,隔着货架看她。冷柜白光打在侧脸,雨声压低。', 'Medium close-up, static. A 32-year-old man in a soaked grey hoodie stands still by the drinks fridge, cold white fridge light on his profile, rain muffled…'], + ]; + function renderFlow() { + $('#view-flow').innerHTML = ` + ${trackHTML(4)} +
当前是未确认草稿:确认后才会交给下一阶段的智能体使用。
+ ${SHOTS.map(([no, d, zh, en]) => `
${no}
${d}
${zh}
${en}
`).join('')}`; + } + $('#view-flow').addEventListener('click', (e) => { + const s = e.target.closest('[data-shot]'); + if (s) { + const shot = SHOTS.find((x) => x[0] === s.dataset.shot); + state.context = shot[0]; + $('#context-bar').classList.add('on'); + $('#context-bar b').textContent = `《雨夜便利店》· 镜头 ${shot[0]}`; + nav('desk'); + setScope('p1'); + selectWorkflow(6); + $('#prompt').value = shot[3]; + $('#prompt').dispatchEvent(new Event('input')); + state.params.duration = shot[1].replace('s', '') === '4' ? '5' : shot[1].replace('s', ''); + renderCommonChips(); renderParams(); + $('#prompt').focus(); + return; + } + if (e.target.closest('[data-stage]')) toast('阶段切换沿用现有五段工作台,本原型不展开'); + if (e.target.closest('[data-todo]')) toast('本原型只演示高频生成链路;该操作沿用现有功能'); + }); + $('#ctx-back').addEventListener('click', () => { state.context = null; $('#context-bar').classList.remove('on'); nav('flow'); }); + + function renderOther(v) { + const desc = { + agents: '五个智能体改为左列表 + 右侧对话;对话里生成的提示词可一键「送到生成台」,直接落到输入台,不再复制粘贴。', + connections: '连接卡与工作流库沿用本原型的状态标签与抽屉:导入就是左侧演示的那个抽屉,四步检查逐条出现;失败项给中文原因与下一步。', + settings: '模型设置与系统设置合并成一个带分组导航的设置页;密钥掩码不回显,连通性测试结果用同一套状态标签。', + more: '窄屏「更多」收纳:全部任务、智能体、ComfyUI 连接、模型与设置。', + }[v] || ''; + $('#view-other').innerHTML = `

${TITLES[v]}

${desc}

本原型聚焦「选择/导入工作流 → 按 JSON 填输入 → 提交 → 切换结果」这条高频链路,该页不做可点演示。

`; + $('#view-other [data-nav-desk]').onclick = () => nav('desk'); + } + + /* ---------------- 键盘 ---------------- */ + const inField = (el) => el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT' || el.isContentEditable); + document.addEventListener('keydown', (e) => { + const mod = e.metaKey || e.ctrlKey; + if (mod && e.key.toLowerCase() === 'k') { e.preventDefault(); if ($('#wf-pop').classList.contains('on')) closeLayer($('#wf-pop')); else openWfPop(true); return; } + if (e.key === 'Escape') { if (closeTop()) { e.preventDefault(); return; } if (composer.classList.contains('expanded')) composer.classList.remove('expanded'); return; } + if (mod && e.key === 'Enter' && state.view === 'desk') { e.preventDefault(); submit(); return; } + if (inField(e.target) || state.view !== 'desk' || layers.some((l) => l.el.id !== 'inspector')) return; + if (e.key === '/') { e.preventDefault(); $('#prompt').focus(); } + else if (e.key === 'ArrowDown' || e.key === 'j') { e.preventDefault(); moveSelection(1); } + else if (e.key === 'ArrowUp' || e.key === 'k') { e.preventDefault(); moveSelection(-1); } + else if (e.key === ' ') { + const v = $('#insp-preview video'); + if (v && !e.target.closest('button')) { e.preventDefault(); v.paused ? v.play() : v.pause(); } + } else if ((e.key === 'Delete' || e.key === 'Backspace') && state.selected) { + const t = takes.find((x) => x.id === state.selected); + if (t && t.status !== 'queued' && t.status !== 'running') removeTake(t); + } + }); + $('#cmd-btn').addEventListener('click', () => openWfPop(true)); + + /* ---------------- 减少动态 ---------------- */ + $('#reduce-toggle').checked = reduceQuery.matches; + if (reduceQuery.matches) root.dataset.reduce = '1'; + $('#reduce-toggle').addEventListener('change', (e) => { root.dataset.reduce = e.target.checked ? '1' : '0'; }); + + /* ---------------- 启动 ---------------- */ + const params = new URLSearchParams(location.search); + if (params.get('reduce') === '1') { root.dataset.reduce = '1'; $('#reduce-toggle').checked = true; } + renderComposer(); + renderParams(); + renderFeed({ scrollToEnd: true }); + renderPreview(false); + updateTray(); + if (params.get('view')) nav(params.get('view')); +})(); diff --git a/prototypes/hel-646-flow-desk/assets/i-t2i-43.jpg b/prototypes/hel-646-flow-desk/assets/i-t2i-43.jpg new file mode 100644 index 00000000..35b8c603 Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/i-t2i-43.jpg differ diff --git a/prototypes/hel-646-flow-desk/assets/v-i2v-35.jpg b/prototypes/hel-646-flow-desk/assets/v-i2v-35.jpg new file mode 100644 index 00000000..55033306 Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-i2v-35.jpg differ diff --git a/prototypes/hel-646-flow-desk/assets/v-i2v-35.mp4 b/prototypes/hel-646-flow-desk/assets/v-i2v-35.mp4 new file mode 100644 index 00000000..5f73c079 Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-i2v-35.mp4 differ diff --git a/prototypes/hel-646-flow-desk/assets/v-ref2v-44.jpg b/prototypes/hel-646-flow-desk/assets/v-ref2v-44.jpg new file mode 100644 index 00000000..a42d605a Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-ref2v-44.jpg differ diff --git a/prototypes/hel-646-flow-desk/assets/v-ref2v-44.mp4 b/prototypes/hel-646-flow-desk/assets/v-ref2v-44.mp4 new file mode 100644 index 00000000..1d87ea0b Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-ref2v-44.mp4 differ diff --git a/prototypes/hel-646-flow-desk/assets/v-t2v-16.jpg b/prototypes/hel-646-flow-desk/assets/v-t2v-16.jpg new file mode 100644 index 00000000..2ecce504 Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-t2v-16.jpg differ diff --git a/prototypes/hel-646-flow-desk/assets/v-t2v-16.mp4 b/prototypes/hel-646-flow-desk/assets/v-t2v-16.mp4 new file mode 100644 index 00000000..38db6f43 Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-t2v-16.mp4 differ diff --git a/prototypes/hel-646-flow-desk/assets/v-t2v-21.jpg b/prototypes/hel-646-flow-desk/assets/v-t2v-21.jpg new file mode 100644 index 00000000..50483a75 Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-t2v-21.jpg differ diff --git a/prototypes/hel-646-flow-desk/assets/v-t2v-21.mp4 b/prototypes/hel-646-flow-desk/assets/v-t2v-21.mp4 new file mode 100644 index 00000000..25e44f2c Binary files /dev/null and b/prototypes/hel-646-flow-desk/assets/v-t2v-21.mp4 differ diff --git a/prototypes/hel-646-flow-desk/index.html b/prototypes/hel-646-flow-desk/index.html new file mode 100644 index 00000000..5934d5c1 --- /dev/null +++ b/prototypes/hel-646-flow-desk/index.html @@ -0,0 +1,156 @@ + + + + + +影工坊 · 流水台交互原型(HEL-646,隔离原型) + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+

生成台

+ +
+
+ 隔离原型 · 不连后端 + + + + +
+ + +
+
+
+ + 来自 《雨夜便利店》· 镜头 S1,生成结果会回填到该镜头 +
+
+
+ + + + +
+ +
+
+
+
+
+ +
+ + + +
+ + +
+
+
+
+
+ + +
+ + +
+ +
+ +
+ + +
+
+ + + + + + + + + + +
+ + + + +
+ + + + diff --git a/prototypes/hel-646-flow-desk/shots/00-现状与流水台对比-生成页.png b/prototypes/hel-646-flow-desk/shots/00-现状与流水台对比-生成页.png new file mode 100644 index 00000000..04a9ce02 Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/00-现状与流水台对比-生成页.png differ diff --git a/prototypes/hel-646-flow-desk/shots/01-选择工作流面板.png b/prototypes/hel-646-flow-desk/shots/01-选择工作流面板.png new file mode 100644 index 00000000..3ab0afe1 Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/01-选择工作流面板.png differ diff --git a/prototypes/hel-646-flow-desk/shots/02-导入JSON四步检查.png b/prototypes/hel-646-flow-desk/shots/02-导入JSON四步检查.png new file mode 100644 index 00000000..7f0ac0ef Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/02-导入JSON四步检查.png differ diff --git a/prototypes/hel-646-flow-desk/shots/03-提交后生成中.png b/prototypes/hel-646-flow-desk/shots/03-提交后生成中.png new file mode 100644 index 00000000..41a9d94e Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/03-提交后生成中.png differ diff --git a/prototypes/hel-646-flow-desk/shots/04-点选历史结果切换播放.png b/prototypes/hel-646-flow-desk/shots/04-点选历史结果切换播放.png new file mode 100644 index 00000000..7b591ce9 Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/04-点选历史结果切换播放.png differ diff --git a/prototypes/hel-646-flow-desk/shots/05-错误就地反馈.png b/prototypes/hel-646-flow-desk/shots/05-错误就地反馈.png new file mode 100644 index 00000000..2d760cce Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/05-错误就地反馈.png differ diff --git a/prototypes/hel-646-flow-desk/shots/06-参考生视频按JSON显示1到9张.png b/prototypes/hel-646-flow-desk/shots/06-参考生视频按JSON显示1到9张.png new file mode 100644 index 00000000..717c5313 Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/06-参考生视频按JSON显示1到9张.png differ diff --git a/prototypes/hel-646-flow-desk/shots/07-窄屏390三态.png b/prototypes/hel-646-flow-desk/shots/07-窄屏390三态.png new file mode 100644 index 00000000..563c5d4e Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/07-窄屏390三态.png differ diff --git a/prototypes/hel-646-flow-desk/shots/08-中屏1024检视区改浮层.png b/prototypes/hel-646-flow-desk/shots/08-中屏1024检视区改浮层.png new file mode 100644 index 00000000..d0794bd4 Binary files /dev/null and b/prototypes/hel-646-flow-desk/shots/08-中屏1024检视区改浮层.png differ diff --git a/prototypes/hel-646-flow-desk/方案.md b/prototypes/hel-646-flow-desk/方案.md new file mode 100644 index 00000000..20bef5a9 --- /dev/null +++ b/prototypes/hel-646-flow-desk/方案.md @@ -0,0 +1,93 @@ +# 影工坊整站方案 · 施工员版「流水台」 + +> 一张桌面走完「选工作流 → 放素材写提示词 → 生成 → 挑结果」,不跳页、不重复找历史。 +> 隔离原型:本目录 `index.html`(双击即可在 Chrome / Edge 打开,不连后端,数据取自测试站真实工作流与任务记录)。 + +## 一、和已有方案的区别 + +| 方案 | 布局 | 交互方式 | +|---|---|---| +| 旧「纸上制片厂」「信号控制台」 | 同一副骨架:左侧文字导航 + 卡片网格 + 三栏表单 | 只换配色 | +| 美术师「放映厅」 | 作品全幅居中的剧场播放器,控件退到边缘 | 以看片挑片为主 | +| **施工员「流水台」** | **60px 图标轨 + 中间记录流 + 底部常驻输入台 + 右侧检视区** | **像对话一样一条条往下生成;工作流决定输入槽;结果就地出现、就地切换** | + +「流水台」主要改的是结构和手感,配色 Token 可以单独替换。白栖知如果更喜欢「放映厅」的色调,可以把「放映厅」的颜色套到「流水台」的结构上。原型当前用的是暖石墨底色,只有主按钮、选中项和「完成」三处用青柠色。 + +## 二、现状走查(测试站 192.168.200.15:8080,1.5.8) + +| # | 现状 | 建议 | 理由 | +|---|---|---|---| +| 1 | 390 宽整站只显示「手机端暂不适配」 | 窄屏改为底部标签栏;输入台收起时只占一行,点开后升成底部抽屉;点结果进入全屏检视 | 主卡验收要求覆盖窄屏 | +| 2 | 「项目 / 创作工作台」两个入口,还要多经一个选择页;生图、生视频、生成任务是三个页面,各有一份历史 | 合并成一个「生成台」,页面形态由所选工作流的用途决定;任务页就是生成台的「全部来源」视图,右上角托盘随时看进度;`/image` `/video` 保留为预选入口 | 少跳页,历史只保留一份 | +| 3 | 生图页左栏被 8 行红色错误占满,输入图和提示词被挤到首屏以下;1024 宽时「开始生成」压住上传区 | 错误收进工作流选择器的状态标签和检视区「参数」页,输入台只留一行「工作流不可用 · 查看原因」 | 高频操作区不让异常信息占满 | +| 4 | 中栏「最近结果」和右栏「历史」是两套列表;视频历史只有缩略图,看不到提示词和状态 | 只保留一条记录流,每条带输入缩略图、提示词、状态和产物 | 一眼能看出哪组参数出了哪个结果 | +| 5 | 「没有进行中的任务」横幅和具体任务分在两处,提交后反馈的位置不固定 | 点「生成」后,记录流底部立即出现「排队」记录;同一位置依次显示进度条和阶段(如「采样 2/4」),完成后换成产物 | 反馈出现在视线所在的位置 | +| 6 | 上传区是一个大虚线框,9 张参考图会占满左栏;没有「上传中」状态,非法文件的报错位置不明确 | 改成 58px 小槽位,显示「已选 n / 9」和序号,上传中加遮罩,错误提示放在槽位下方;整个输入台都能拖入 | 放满素材后仍看得到提示词和按钮 | +| 7 | 点选历史后播放器直接替换,不能用键盘切换 | 点选时 150ms 淡入;↑ ↓ / J K 即时切换,不加动画;空格播放 | 高频操作不加动画(Emil 规范) | +| 8 | 每次删除都弹确认框 | 单条记录删除后立即隐藏,并提供 5 秒撤销,窗口结束后才真正调用删除接口;删项目、删工作流等大操作仍然弹确认 | 撤销比确认更快,也更不容易误删 | +| 9 | `Qwen_image_2.1_00003.png` 在服务器上已不存在,结果区和任务页显示浏览器裂图 | 显示明确的「文件缺失」状态,并提供「用相同参数重做 / 移除记录」 | 裂图会让人以为系统坏了 | +| 10 | 侧栏常驻红色「恒源云 连接失败」,但生图实际走的是已连通的「本机 ComfyUI-4080」;默认连接恰好是连不上的那台 | 顶栏和输入台只显示「本次生成要用的连接」,可以切换;连接不通时,生成按钮旁直接写原因 | 避免让人误以为不能生成 | +| 11 | 「minimaxh3-文生图加速版」实际被判定为文生视频 | 选择器按用途分组,并显示输入槽摘要(仅提示词 / 首帧 ×1 / 参考图 1–9 张) | 名称是用户起的,用途以 JSON 为准 | +| 12 | 8 个参数全部平铺 | 比例、时长、种子做成输入台上的芯片,其余参数折叠到检视区;每项标注「原值」,改过的高亮并计数 | 多数时候只改提示词和素材 | +| 13 | 失败记录把整段英文 HTTP 400 原文铺开 | 先给一行中文结论(如「连接上缺 3 个模型文件」),详情可展开;重试前先提示仍缺模型 | 可读,也不丢失信息 | +| 14 | 创作流程里的生成和独立生视频是两套界面 | 「生成本镜视频」打开生成台,并带上下文条(「来自《雨夜便利店》· 镜头 S1,结果回填」)和一键返回 | 同一套输入台,只需学一次 | +| 15 | 150px 文字侧栏共 9 项 | 60px 图标轨(悬停显示名称)加 Ctrl K 全局搜索 | 把宽度让给作品。代价是新用户第一次需要悬停识别图标 | + +## 三、结构与操作方式 + +- **桌面 ≥1180**:左边 60px 图标轨;顶栏放标题、范围胶囊(全部来源 / 独立创作 / 某项目)、Ctrl K、任务托盘和本次连接;中间记录流按时间从上到下,最新一条在底部,紧贴输入台;右侧 420px 检视区分「结果 / 参数」两个页签。 +- **中屏 761–1179**:检视区改为右侧浮层,点结果时滑入;其余结构不变。 +- **窄屏 ≤760**:底部标签栏(项目 / 创作 / 生成 / 更多);输入台收起时只有一行,聚焦后升成底部抽屉;工作流面板改为底部弹层;检视区全屏显示,可关闭返回。 +- **工作流选择**:点输入台上的工作流芯片,面板从芯片处弹出,按五类用途分组,每行显示输入槽摘要、绑定连接和状态(可用 / 未试运行 / 上次失败 / 不可用)。支持输入过滤、↑↓ 选择、Enter 使用,底部是「导入 ComfyUI 工作流 JSON…」。 +- **导入**:右侧抽屉。粘贴、拖入或选择文件后自动检查,依次是:1 文件结构 → 2 用途与输入槽(不确定时让用户选)→ 3 对照连接上的节点与模型 → 4 可选试运行(只有拿到可下载、类型正确的产物才算通过)。保存后自动选中,输入台立刻按这份 JSON 显示输入槽。 +- **输入槽只随 JSON 出现**:文生图 / 文生视频没有图片槽;图生图显示「输入图 ×1」;图生视频显示「首帧图 ×1」;参考生视频显示「参考图 1–9 张」。原型不画参考视频 / 音频入口,因为当前三份真实 JSON 没有这类连线。切换工作流时已放入的图片会保留,按新槽位的上限截断。 +- **结果切换**:点记录会在检视区淡入;键盘 ↑ ↓ 即时切换;「复用」把工作流、素材和参数放回输入台;图片结果可以「送入当前图片槽」。 + +## 四、动效(按 emil-skills `animate` 与 `review-animations/STANDARDS` 核对) + +| 场景 | 频率 | 做法 | 参数 | +|---|---|---|---| +| 按钮 / 芯片按下 | 高 | `scale(0.97)` | 120ms · `cubic-bezier(0.23,1,0.32,1)` | +| 点芯片打开工作流面板 | 中 | 从芯片方向 `scale(0.96)`→1,同时淡入 | 180ms · 同上 | +| Ctrl K 打开面板 / ↑↓ 切换结果 | 高·键盘 | **不做动画** | 0 | +| 导入抽屉 / 中屏检视区 | 偶尔 | `translateX(100%)`→0,用 transition,中途可反向 | 280ms · `cubic-bezier(0.32,0.72,0,1)` | +| 提交后新记录出现 | 每次 | 淡入 + 上移 8px(`@starting-style`) | 220ms · ease-out | +| 进度条 | 持续 | `transform: scaleX()` | 400ms · linear | +| 完成后缩略图替换 / 点选切换结果 | 每次 | 透明度交叉淡入 | 150ms · ease | +| 删除记录 | 偶尔 | 左移 12px 并淡出,Toast 提供撤销 | 200ms / 5 秒撤销窗口 | +| Toast | 偶尔 | 从下方进出,用 transition 不用 keyframes,可被打断 | 220ms | +| 导入检查结果 | 偶尔 | 逐条出现,间隔 60ms,不阻塞操作 | 200ms | + +- 只动 `transform` 和 `opacity`;悬停效果只在 `(hover: hover) and (pointer: fine)` 下生效。 +- 减少动态效果:系统开启 `prefers-reduced-motion` 时自动生效,原型顶栏也有手动开关。开启后去掉所有位移,只保留不超过 120ms 的透明度变化。 +- 全部动效用 CSS transition 实现,**不引入新依赖**。 + +**性能风险与代价**:① 记录流可能有上百条视频。缩略图用封面图,检视区只挂一个 `