Skip to content

PRINTFILM: AI short-video marketing and AI short-drama creation platform

Frontend: update drama storyboard UI

yic229f53a8757
diff --git a/frontend/src/api.ts b/frontend/src/api.ts
index 25d228c..7c56066 100644
--- a/frontend/src/api.ts
+++ b/frontend/src/api.ts
@@ -148,6 +148,22 @@ export type Project = {
created_at: string
updated_at: string
shots: Shot[]
+ active_tasks?: Array<{
+ id: number
+ domain: string
+ task_type: string
+ status: string
+ current_step_key?: string | null
+ current_step_status?: string | null
+ progress_percent?: number
+ cancel_requested?: boolean
+ provider_task_id?: string | null
+ error_message?: string | null
+ project_id?: number | null
+ shot_id?: number | null
+ created_at?: string
+ updated_at?: string
+ }>
}
export type User = {
@@ -388,6 +404,7 @@ export const api = {
published?: boolean
created_at: string
updated_at?: string
+ active_tasks?: Project['active_tasks']
}>
meta: { page: number; page_size: number; total: number }
stats: { total: number; generating: number; done: number; published: number }
diff --git a/frontend/src/components/drama/SeedanceRulesModal.tsx b/frontend/src/components/drama/SeedanceRulesModal.tsx
index 2b3fff2..44e75a0 100644
--- a/frontend/src/components/drama/SeedanceRulesModal.tsx
+++ b/frontend/src/components/drama/SeedanceRulesModal.tsx
@@ -231,13 +231,6 @@ export function SeedanceRulesModal({ open, onClose }: Props) {
会按剧本与资产重新规划各镜脚本与 @duration 结构;进行中的视频生成需等待完成后再操作,以免状态冲突。空镜须用「空镜:…」等画面写法,勿写成对白。
</p>
- <h4>分镜板多宫格(路径 D)</h4>
- <ul className="seedance-rules-list">
- <li>顶栏「导入分镜板」:上传 N 宫格图并指定行列</li>
- <li>≤4 格 → D-1 单镜多段时间戳;≥5 格 → D-2 每格一镜</li>
- <li>可同时选择六式剪辑节奏(呼吸/心跳/海浪等)写入各段或各镜时长</li>
- <li>正文自动注入「不复刻网格边框/编号/分隔线」约束</li>
- </ul>
</div>
) : null}
</div>
diff --git a/frontend/src/components/drama/StoryboardGridImportModal.tsx b/frontend/src/components/drama/StoryboardGridImportModal.tsx
deleted file mode 100644
index b0a6d35..0000000
--- a/frontend/src/components/drama/StoryboardGridImportModal.tsx
+++ /dev/null
@@ -1,262 +0,0 @@
-/** 分镜板多宫格导入:裁格 → 上传素材 → D-1 单镜多段 / D-2 每格一镜 */
-import { useMemo, useState } from 'react'
-import Modal from '../../components/ui/Modal'
-import { dramaApi, type DramaAsset, type DramaFragment } from '../../api/drama'
-import {
- DRAMA_EDIT_RHYTHM_PRESETS,
- suggestEpisodeFragmentDurations,
- suggestRhythmDurations,
- type DramaEditRhythmId,
-} from '../../lib/dramaEditRhythm'
-import {
- buildStoryboardD1Content,
- buildStoryboardD2CellContent,
- resolveStoryboardImportMode,
- splitStoryboardGridImage,
-} from '../../lib/dramaStoryboardGrid'
-
-type Props = {
- open: boolean
- onClose: () => void
- projectId: number
- episodeId: number
- fragments: DramaFragment[]
- onImported: (next: DramaFragment[], assets: DramaAsset[]) => void
-}
-
-// 分镜板导入弹窗
-export function StoryboardGridImportModal({
- open,
- onClose,
- projectId,
- episodeId,
- fragments,
- onImported,
-}: Props) {
- /*
- * file 宫格图
- * rows / cols 行列
- * rhythmId 节奏公式
- * busy / error / previewMode 状态
- */
- const [file, setFile] = useState<File | null>(null)
- const [rows, setRows] = useState(2)
- const [cols, setCols] = useState(2)
- const [rhythmId, setRhythmId] = useState<DramaEditRhythmId>('breath')
- const [busy, setBusy] = useState(false)
- const [error, setError] = useState('')
-
- const cellCount = rows * cols
- const mode = useMemo(() => resolveStoryboardImportMode(cellCount), [cellCount])
- const previewDurations = useMemo(
- () =>
- mode === 'd1'
- ? suggestRhythmDurations(cellCount, rhythmId, Math.min(15, 4 * cellCount))
- : suggestEpisodeFragmentDurations(cellCount, rhythmId, 10),
- [cellCount, mode, rhythmId],
- )
-
- // 执行导入
- async function handleImport() {
- if (!file) {
- setError('请先选择分镜板图片')
- return
- }
- setBusy(true)
- setError('')
- try {
- const cells = await splitStoryboardGridImage(file, rows, cols)
- const uploaded: DramaAsset[] = []
- for (const cell of cells) {
- const stub = await dramaApi.createAsset({
- project_id: projectId,
- type: 'material',
- asset_type: 'material',
- name: `分镜板 ${cell.row + 1}-${cell.col + 1}`,
- params: {
- storyboardCell: true,
- cellIndex: cell.index,
- source: 'storyboard_grid_import',
- },
- })
- const media = new File([cell.blob], cell.fileName, { type: 'image/jpeg' })
- const done = await dramaApi.uploadAssetMedia(stub.id, media)
- uploaded.push(done)
- }
-
- const durations = previewDurations
- let nextFragments: DramaFragment[]
-
- if (mode === 'd1') {
- const cover = uploaded[0]?.cover || uploaded[0]?.url || ''
- const assetIds = uploaded.map((a) => a.id)
- const content = buildStoryboardD1Content(cells.length, durations)
- const base = fragments[0]
- nextFragments = [
- {
- id: base?.id || 0,
- episode_id: episodeId,
- sort_order: 0,
- content,
- cover,
- video: '',
- duration_sec: durations.reduce((a, b) => a + b, 0),
- asset_ids: assetIds,
- params: {
- ...(base?.params && typeof base.params === 'object' ? base.params : {}),
- storyboardImport: 'd1',
- rhythmId,
- user_edited: true,
- },
- },
- ...fragments.slice(1).map((f, i) => ({ ...f, sort_order: i + 1 })),
- ]
- } else {
- nextFragments = uploaded.map((asset, index) => {
- const sec = durations[index] ?? 8
- return {
- id: 0,
- episode_id: episodeId,
- sort_order: index,
- content: buildStoryboardD2CellContent(index, sec),
- cover: asset.cover || asset.url || '',
- video: '',
- duration_sec: sec,
- asset_ids: [asset.id],
- params: {
- storyboardImport: 'd2',
- rhythmId,
- cellIndex: index,
- user_edited: true,
- },
- }
- })
- }
-
- const saved = await dramaApi.saveFragments(
- episodeId,
- nextFragments.map((f, i) => ({
- sort_order: i,
- content: f.content,
- cover: f.cover,
- video: f.video || '',
- duration_sec: f.duration_sec ?? 8,
- params: f.params || {},
- asset_ids: f.asset_ids || [],
- })),
- )
- onImported(saved.fragments || [], uploaded)
- onClose()
- } catch (err) {
- setError(err instanceof Error ? err.message : '导入失败')
- } finally {
- setBusy(false)
- }
- }
-
- return (
- <Modal
- open={open}
- onClose={busy ? () => undefined : onClose}
- title="导入分镜板(多宫格)"
- size="lg"
- className="pf-help-modal"
- footer={
- <>
- <button type="button" className="pf-btn pf-btn-ghost pf-btn-sm" disabled={busy} onClick={onClose}>
- 取消
- </button>
- <button
- type="button"
- className="pf-btn pf-btn-lime pf-btn-sm"
- disabled={busy || !file}
- onClick={() => void handleImport()}
- >
- {busy ? '导入中…' : mode === 'd1' ? '导入为单镜多段' : '导入为多镜'}
- </button>
- </>
- }
- >
- <div className="drama-storyboard-import">
- <p className="drama-storyboard-import-lede">
- 上传 N 宫格分镜板。≤4 格走 D-1(单镜时间戳);≥5 格走 D-2(每格一镜)。生成时会注入「不复刻网格」约束。
- </p>
-
- <label className="drama-storyboard-import-file">
- <span>分镜板图片</span>
- <input
- type="file"
- accept="image/*"
- disabled={busy}
- onChange={(e) => {
- setFile(e.target.files?.[0] || null)
- setError('')
- }}
- />
- </label>
-
- <div className="drama-storyboard-import-row">
- <label>
- 行
- <input
- type="number"
- min={1}
- max={6}
- value={rows}
- disabled={busy}
- onChange={(e) => setRows(Number(e.target.value) || 1)}
- />
- </label>
- <label>
- 列
- <input
- type="number"
- min={1}
- max={6}
- value={cols}
- disabled={busy}
- onChange={(e) => setCols(Number(e.target.value) || 1)}
- />
- </label>
- <em>
- {cellCount} 格 · {mode === 'd1' ? 'D-1 单镜多段' : 'D-2 每格一镜'}
- </em>
- </div>
-
- <div className="drama-storyboard-import-rhythm">
- <strong>剪辑节奏</strong>
- <div className="drama-storyboard-import-rhythm-chips">
- {DRAMA_EDIT_RHYTHM_PRESETS.map((preset) => (
- <button
- key={preset.id}
- type="button"
- className={rhythmId === preset.id ? 'is-active' : undefined}
- disabled={busy}
- title={preset.hint}
- onClick={() => setRhythmId(preset.id)}
- >
- {preset.label}
- </button>
- ))}
- </div>
- <p>
- 建议时长:{previewDurations.map((s) => `${s}s`).join(' · ')}
- {mode === 'd2' ? '(将写入各镜)' : '(写入本镜各段)'}
- </p>
- </div>
-
- {mode === 'd2' ? (
- <p className="drama-storyboard-import-warn">
- D-2 会用新分镜替换本集现有分镜列表(原视频会被清空,请确认后导入)。
- </p>
- ) : (
- <p className="drama-storyboard-import-note">
- D-1 会改写第 1 镜脚本与封面,并挂上各格素材参考;其余分镜保留。
- </p>
- )}
-
- {error ? <p className="drama-storyboard-import-error">{error}</p> : null}
- </div>
- </Modal>
- )
-}
diff --git a/frontend/src/lib/dramaStoryboardGrid.ts b/frontend/src/lib/dramaStoryboardGrid.ts
deleted file mode 100644
index 90d7078..0000000
--- a/frontend/src/lib/dramaStoryboardGrid.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 分镜板多宫格拆分与路径 D 脚本组装(对齐 EPISODE_RULES / MapleShaw 路径 D)
- * D-1:≤4 格 → 单镜多段 @duration;D-2:≥5 格 → 每格一镜
- */
-
-/** 禁止模型复刻网格 UI 的画面约束 */
-export const STORYBOARD_NO_GRID_CUE =
- '【画面约束】不复刻分镜板的网格边框、格子编号与分隔线,仅演绎各格画面内容'
-
-export type StoryboardGridCell = {
- index: number
- row: number
- col: number
- blob: Blob
- fileName: string
-}
-
-export type StoryboardImportMode = 'd1' | 'd2'
-
-// 按格数选择 D-1 / D-2
-export function resolveStoryboardImportMode(cellCount: number): StoryboardImportMode {
- return cellCount <= 4 ? 'd1' : 'd2'
-}
-
-// 将宫格图按 rows×cols 裁成独立单元格 Blob
-export async function splitStoryboardGridImage(
- file: File,
- rows: number,
- cols: number,
-): Promise<StoryboardGridCell[]> {
- const safeRows = Math.max(1, Math.min(6, Math.floor(rows)))
- const safeCols = Math.max(1, Math.min(6, Math.floor(cols)))
- const bitmap = await createImageBitmap(file)
- try {
- const cellW = Math.floor(bitmap.width / safeCols)
- const cellH = Math.floor(bitmap.height / safeRows)
- if (cellW < 8 || cellH < 8) {
- throw new Error('宫格过小,请换更高清分镜板或减少行列数')
- }
- const cells: StoryboardGridCell[] = []
- for (let row = 0; row < safeRows; row++) {
- for (let col = 0; col < safeCols; col++) {
- const canvas = document.createElement('canvas')
- canvas.width = cellW
- canvas.height = cellH
- const ctx = canvas.getContext('2d')
- if (!ctx) throw new Error('无法裁剪分镜板')
- ctx.drawImage(
- bitmap,
- col * cellW,
- row * cellH,
- cellW,
- cellH,
- 0,
- 0,
- cellW,
- cellH,
- )
- const blob = await new Promise<Blob>((resolve, reject) => {
- canvas.toBlob(
- (b) => (b ? resolve(b) : reject(new Error('单元格导出失败'))),
- 'image/jpeg',
- 0.92,
- )
- })
- const index = cells.length
- cells.push({
- index,
- row,
- col,
- blob,
- fileName: `storyboard_r${row + 1}c${col + 1}.jpg`,
- })
- }
- }
- return cells
- } finally {
- bitmap.close()
- }
-}
-
-// D-1:单镜多段时间戳脚本(格图作参考,正文不写网格)
-export function buildStoryboardD1Content(
- cellCount: number,
- durations: number[],
-): string {
- const lines = [STORYBOARD_NO_GRID_CUE]
- for (let i = 0; i < cellCount; i++) {
- const sec = durations[i] ?? 4
- lines.push(`@duration:${sec}`)
- lines.push(
- `【画面·无配音仅环境音】按分镜板第 ${i + 1} 格画面演绎(从左到右、从上到下),主体动作连贯。`,
- )
- }
- return lines.join('\n')
-}
-
-// D-2:单格一镜的默认画面正文
-export function buildStoryboardD2CellContent(
- cellIndex: number,
- durationSec: number,
-): string {
- return [
- STORYBOARD_NO_GRID_CUE,
- `@duration:${durationSec}`,
- `【画面·无配音仅环境音】按分镜板第 ${cellIndex + 1} 格画面演绎,不复刻网格。`,
- ].join('\n')
-}
diff --git a/frontend/src/lib/status.ts b/frontend/src/lib/status.ts
index c411205..5773cab 100644
--- a/frontend/src/lib/status.ts
+++ b/frontend/src/lib/status.ts
@@ -26,6 +26,17 @@ export function isRunning(status: string) {
return RUNNING.has(status)
}
+export function hasActiveTasks(project: {
+ active_tasks?: Array<{ status: string; cancel_requested?: boolean | null }> | null
+}) {
+ const activeStatuses = ['pending', 'leased', 'running', 'awaiting_poll', 'awaiting_review']
+ return Boolean(
+ project.active_tasks?.some(
+ (task) => !task.cancel_requested && activeStatuses.includes(task.status),
+ ),
+ )
+}
+
/**
* Prefer stage inferred from shot assets when status is still SCRIPTING
* (e.g. continue-generate briefly labeled wrong, or worker lag).
diff --git a/frontend/src/pages/HistoryPage.tsx b/frontend/src/pages/HistoryPage.tsx
index 4e81910..ec0c43d 100644
--- a/frontend/src/pages/HistoryPage.tsx
+++ b/frontend/src/pages/HistoryPage.tsx
@@ -25,7 +25,7 @@ import {
triggerBlobDownload,
zipVideosClient,
} from '../lib/clientDownload'
-import { isRunning, STATUS_CN, statusTone } from '../lib/status'
+import { hasActiveTasks, isRunning, STATUS_CN, statusTone } from '../lib/status'
import { pageCountOf } from '../lib/pagination'
import { formatDateTime, useI18n } from '../i18n'
@@ -110,7 +110,9 @@ export default function HistoryPage() {
} | null>(null)
const hasRunning = useMemo(
- () => items.some((p) => isRunning(p.status) && p.progress < 100) || stats.generating > 0,
+ () =>
+ items.some((p) => (isRunning(p.status) && p.progress < 100) || hasActiveTasks(p)) ||
+ stats.generating > 0,
[items, stats.generating],
)
diff --git a/frontend/src/pages/drama/EpisodeEditHeaderControls.tsx b/frontend/src/pages/drama/EpisodeEditHeaderControls.tsx
index f4233aa..caae4fb 100644
--- a/frontend/src/pages/drama/EpisodeEditHeaderControls.tsx
+++ b/frontend/src/pages/drama/EpisodeEditHeaderControls.tsx
@@ -274,7 +274,10 @@ export function EpisodeEditHeaderControls({
/>
<span>
用上一镜尾帧衔接
- <em>有角色/场景参考时以参考图附带尾帧(不可与 first_frame 混用)</em>
+ <em>
+ 默认关闭。开启后按镜序生成;关闭后默认并发生成。有角色/场景参考时以参考图附带尾帧(不可与
+ first_frame 混用)
+ </em>
</span>
</label>
</div>
diff --git a/frontend/src/pages/drama/EpisodesStep.tsx b/frontend/src/pages/drama/EpisodesStep.tsx
index e3be0cf..b2f17d4 100644
--- a/frontend/src/pages/drama/EpisodesStep.tsx
+++ b/frontend/src/pages/drama/EpisodesStep.tsx
@@ -25,6 +25,14 @@ type EpisodeSummary = {
// 读取分集 AI 分镜状态
function readPlanStatus(ep: DramaEpisode): string {
+ const active = (ep.active_tasks || []).find((task) => task.task_type === 'fragment_plan')
+ if (
+ active &&
+ !active.cancel_requested &&
+ ['pending', 'leased', 'running', 'awaiting_poll', 'awaiting_review'].includes(active.status)
+ ) {
+ return 'generating'
+ }
const st = ep.params?.fragment_plan_status
return typeof st === 'string' ? st : ''
}
@@ -32,6 +40,17 @@ function readPlanStatus(ep: DramaEpisode): string {
// 汇总单集分镜与视频进度
function summarizeEpisode(ep: DramaEpisode): EpisodeSummary {
const frags = ep.fragments || []
+ const activeFragmentIds = new Set<number>()
+ for (const task of ep.active_tasks || []) {
+ if (
+ task.task_type === 'fragment_video' &&
+ typeof task.fragment_id === 'number' &&
+ !task.cancel_requested &&
+ ['pending', 'leased', 'running', 'awaiting_poll', 'awaiting_review'].includes(task.status)
+ ) {
+ activeFragmentIds.add(task.fragment_id)
+ }
+ }
let videoDone = 0
let videoRunning = 0
let videoFailed = 0
@@ -41,7 +60,7 @@ function summarizeEpisode(ep: DramaEpisode): EpisodeSummary {
totalSec += frag.duration_sec && frag.duration_sec > 0 ? frag.duration_sec : 8
const st = readFragmentGenerationStatus(frag).status
if (st === 'done') videoDone += 1
- else if (st === 'queued' || st === 'running') videoRunning += 1
+ else if (st === 'queued' || st === 'running' || activeFragmentIds.has(frag.id)) videoRunning += 1
else if (st === 'failed') videoFailed += 1
if (!previewUrl) {
const raw = (frag.cover || frag.video || '').trim()
diff --git a/frontend/src/pages/drama/drama.css b/frontend/src/pages/drama/drama.css
index 7a44a4b..036affa 100644
--- a/frontend/src/pages/drama/drama.css
+++ b/frontend/src/pages/drama/drama.css
@@ -3203,102 +3203,6 @@
border: 1px solid #e2e8f0;
}
-.drama-storyboard-import {
- display: flex;
- flex-direction: column;
- gap: 14px;
-}
-
-.drama-storyboard-import-lede {
- margin: 0;
- font-size: 13px;
- line-height: 1.5;
- color: #475569;
-}
-
-.drama-storyboard-import-file {
- display: flex;
- flex-direction: column;
- gap: 6px;
- font-size: 12px;
- color: #0f172a;
-}
-
-.drama-storyboard-import-row {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 12px;
- font-size: 12px;
-}
-
-.drama-storyboard-import-row label {
- display: inline-flex;
- align-items: center;
- gap: 6px;
-}
-
-.drama-storyboard-import-row input {
- width: 64px;
- height: 30px;
- border: 1px solid #e2e8f0;
- border-radius: 8px;
- padding: 0 8px;
- font: inherit;
-}
-
-.drama-storyboard-import-row em {
- font-style: normal;
- color: #64748b;
-}
-
-.drama-storyboard-import-rhythm strong {
- display: block;
- margin-bottom: 8px;
- font-size: 12px;
-}
-
-.drama-storyboard-import-rhythm-chips {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
-}
-
-.drama-storyboard-import-rhythm-chips button {
- height: 28px;
- padding: 0 10px;
- border: 1px solid #e2e8f0;
- border-radius: 999px;
- background: #fff;
- font-size: 12px;
- cursor: pointer;
-}
-
-.drama-storyboard-import-rhythm-chips button.is-active {
- border-color: #111;
- background: #0f172a;
- color: #fff;
-}
-
-.drama-storyboard-import-rhythm p,
-.drama-storyboard-import-note,
-.drama-storyboard-import-warn {
- margin: 8px 0 0;
- font-size: 12px;
- line-height: 1.45;
- color: #64748b;
-}
-
-.drama-storyboard-import-warn {
- color: #9a3412;
-}
-
-.drama-storyboard-import-error {
- margin: 0;
- font-size: 12px;
- color: #be123c;
-}
-
.drama-ep-ref-strip {
display: flex;
gap: 8px;
@@ -4889,15 +4793,19 @@
}
.drama-gen-fab-item-main {
+ flex: 1;
min-width: 0;
}
.drama-gen-fab-name {
- display: block;
+ display: -webkit-box;
+ overflow: hidden;
font-size: 13px;
font-weight: 600;
color: #111;
line-height: 1.35;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
}
.drama-gen-fab-type {
@@ -4932,11 +4840,12 @@
.drama-gen-fab-foot {
display: flex;
- align-items: center;
+ align-items: flex-start;
gap: 8px;
padding: 10px 14px 14px;
border-top: 1px solid var(--drama-line, #e5e7eb);
font-size: 11px;
+ line-height: 1.45;
color: var(--drama-muted, #6b7280);
flex-shrink: 0;
}
diff --git a/frontend/src/pages/studio/StoryboardPage.tsx b/frontend/src/pages/studio/StoryboardPage.tsx
index f270491..56f43b8 100644
--- a/frontend/src/pages/studio/StoryboardPage.tsx
+++ b/frontend/src/pages/studio/StoryboardPage.tsx
@@ -110,6 +110,15 @@ function boardStepIndex(project: Project) {
return 3
}
+function hasActiveUnifiedTasks(project: Project | null): boolean {
+ const activeStatuses = ['pending', 'leased', 'running', 'awaiting_poll', 'awaiting_review']
+ return Boolean(
+ project?.active_tasks?.some(
+ (task) => !task.cancel_requested && activeStatuses.includes(task.status),
+ ),
+ )
+}
+
export default function StoryboardPage() {
const { id } = useParams()
const projectId = Number(id)
@@ -157,7 +166,7 @@ export default function StoryboardPage() {
if (!project) return
// Only poll while pipeline is actively running — idle checkpoints
// (IMAGE_READY / VIDEO_READY / SCRIPT_READY) must not spin forever.
- if (!isRunning(project.status)) return
+ if (!isRunning(project.status) && !hasActiveUnifiedTasks(project)) return
const timer = setInterval(() => {
api
.getProject(project.id)
@@ -176,7 +185,7 @@ export default function StoryboardPage() {
return () => document.removeEventListener('click', onDoc)
}, [menuShotId])
- const running = Boolean(project && isRunning(project.status))
+ const running = Boolean(project && (isRunning(project.status) || hasActiveUnifiedTasks(project)))
const step = project ? boardStepIndex(project) : 3
const totalDuration = useMemo(
() => (project?.shots || []).reduce((s, x) => s + (Number(x.duration) || 0), 0),