From ff2e077979ce9ac36c192fadb5fb3e7a29b072cc Mon Sep 17 00:00:00 2001 From: huyan Date: Fri, 31 Jul 2026 07:31:01 +0800 Subject: [PATCH 1/2] feat(quick-start): add workflow-backed creation flow Quick Start needs to drive the frontend WorkflowRun without entering the editor. Add the page UI and an injectable service that prepares a project and delegates execution to WorkflowController. Unconfigured production wiring now fails explicitly instead of falling back to fake data. --- frontend/src/pages/quick-start/index.tsx | 493 +++++++++++++++++++++- frontend/src/pages/quick-start/service.ts | 111 +++++ 2 files changed, 599 insertions(+), 5 deletions(-) create mode 100644 frontend/src/pages/quick-start/service.ts diff --git a/frontend/src/pages/quick-start/index.tsx b/frontend/src/pages/quick-start/index.tsx index 1ffe9fe..16522ad 100644 --- a/frontend/src/pages/quick-start/index.tsx +++ b/frontend/src/pages/quick-start/index.tsx @@ -1,9 +1,492 @@ -/** 快速开始。 */ -export function QuickStartPage() { +import { useEffect, useState, type FormEvent } from 'react' +import { useNavigate, useParams } from 'react-router' + +import { + WORKFLOW_STEP_ORDER, + type CharacterTemplateWorkflowStep, + type WorkflowRevision, + type WorkflowRun, + type WorkflowStep, + type WorkflowStepType, +} from '@/entities' +import { unavailableQuickStartService, type QuickStartService } from './service' + +export type { + CreateQuickStartServiceOptions, + PrepareQuickStartProject, + QuickStartService, +} from './service' + +const STEP_LABELS: Record = { + 'character-setup': '角色设定', + 'character-template': '角色图', + 'template-candidate': '候选选择', + 'action-setup': '动作设定', + 'first-frame': '动作首帧', + 'complete-animation': '完整动画', + review: '审核', + export: '导出', +} + +const EXAMPLES = [ + { + label: '像素守夜人', + prompt: '一位提着风灯、披深色斗篷的像素守夜人', + }, + { + label: '轻装信使', + prompt: '轻装信使,侧视像素风,轮廓清晰,动作轻快', + }, +] as const + +export interface QuickStartPageProps { + /** + * 页面测试与后续生产组合可以注入同一份服务实例。 + * 默认实现明确不可用,直到真实 Project / Generation / Task 实现到位。 + */ + service?: QuickStartService +} + +/** Quick Start 独立完成 AI 入口;它不跳转 Workflow Editor。 */ +export function QuickStartPage({ service = unavailableQuickStartService }: QuickStartPageProps) { + const { runId } = useParams() + + return runId ? ( + + ) : ( + + ) +} + +function QuickStartInput({ service }: { service: QuickStartService }) { + const navigate = useNavigate() + const [prompt, setPrompt] = useState('') + const [submitting, setSubmitting] = useState(false) + const [error, setError] = useState(null) + const unavailableReason = service.unavailableReason + + async function submit(event: FormEvent) { + event.preventDefault() + const normalizedPrompt = prompt.trim() + if (!normalizedPrompt || submitting || unavailableReason) return + + setSubmitting(true) + setError(null) + try { + const run = await service.start(normalizedPrompt) + navigate(`/quick-start/${encodeURIComponent(run.id)}`) + } catch (cause) { + setError(errorMessage(cause, '创建失败,请稍后重试')) + } finally { + setSubmitting(false) + } + } + + return ( +
+ + +
+
+
+

+ QUICK START / CREATE CHARACTER +

+

+ 用一句角色设定, +
+ 开始一条可追踪的制作流程。 +

+
+ + AI 快捷创作 + +
+ +
+ + + +
+ +
+
+ {EXAMPLES.slice(1).map((example) => ( + + ))} +
+ +
void submit(event)} + className="grid gap-3 rounded-[1.4rem] border border-[#bdc7bf] bg-[#f7f8f4] p-4 shadow-[0_22px_60px_rgba(31,43,35,0.12)] sm:grid-cols-[1fr_auto]" + > +