2145 lines
121 KiB
TypeScript
2145 lines
121 KiB
TypeScript
/**
|
||
* 分镜与脚本工作台(图1 模块 02 / 图2 节点 ②③⑤⑪)
|
||
*
|
||
* 页面结构按「编导实际怎么用」分层:
|
||
* 顶栏 —— 总量/时长/预检一眼可见,视图切换 + 搜索 + 筛选 + 导出
|
||
* 选择条 —— 勾选镜头后出现的批量操作(复制 / 移动 / 统一改参数 / 删除)
|
||
* 看板 —— 缩略图卡片(网格)或分镜表(行),拖拽即可改镜序
|
||
* 检查器 —— 常驻右侧:镜头参数 / 资产绑定 / 提示词版本 / 产物预览
|
||
*
|
||
* 数据:列表走轻量的 /shots/board(含逐镜预检),只在选中时按需拉 /shots/{id} 全量详情,
|
||
* 几十上百个镜头也不会把首屏压垮。
|
||
*/
|
||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||
import { Link, useSearchParams } from 'react-router-dom'
|
||
import * as api from '../../api/client'
|
||
import { canvasFor, fmtAgo, fmtTime, opt, reviewBadge, statusLabel } from '../../lib/format'
|
||
import { fromAsset, fromShot, fromShotGroup, thumbUrl, type MediaItem } from '../../lib/media'
|
||
import { cn } from '../../lib/cn'
|
||
import { useAutoRefresh, useLocalStorage } from '../../hooks'
|
||
import { MultiSelect, Select } from '../../components/forms'
|
||
import { AudioPlay } from '../../components/media/AudioPlay'
|
||
import { MediaThumb } from '../../components/media/MediaThumb'
|
||
import {
|
||
|
||
capsOf, defaultFor, findByPair, loadModels, modelsOf, parseRef, projectVideoModel, useModelsStore
|
||
} from '../../stores/models'
|
||
import { refresh, useProjectStore } from '../../stores/project'
|
||
import { options, useSystemStore } from '../../stores/system'
|
||
import { notify } from '../../stores/notice'
|
||
import { confirmAction } from '../../stores/confirm'
|
||
import { openPreview, usePreviewOpen } from '../../stores/preview'
|
||
import { PageHead, ActionGroup, Actions, BarRight, Between, BLOCK_TONE, Button, CARD_ROW, Check, Checkbox, Chip, ChipBar, CloseButton, Ctlbar, DRAWER_ACTIONS, DRAWER_BODY, DRAWER_HEAD, DRAWER_TITLE, Divider, Empty, ErrorText, ExportMenu, ExtLink, Field, FieldBlock, FilePick, FormGrid, FormRow, IconText, Input, LINK_CLS, LinkButton, MUTED, MUTED_MONO, MaybeNumberInput, Mono, Notice, NumberInput, PageStack, Panel, PanelHead, Row, Scrim, SearchInput, SectionTitle, SkeletonBlock, Spinner, Status, TAG_DENSE, Table, Tabs, Tag, TagGroup, TextArea, Toolbar, Value, ViewSwitch, cellWrap, type Columns } from '../../components/ui'
|
||
import { floatingLayerOpen, LAYER } from '../../lib/layers'
|
||
import { IconAdd, IconArrowDown, IconArrowUp, IconAudit, IconCheck, IconChevronUp, IconClose, IconCompose, IconCopy, IconDelete, IconDownload, IconDragHandle, IconEdit, IconEye, IconGrid, IconImage, IconListOrdered, IconMic, IconParams, IconPlayCircle, IconReload, IconRetry, IconSearch, IconSound, IconToTop, IconUpload, IconVideo, IconWarn } from '../../components/icons'
|
||
|
||
type ViewMode = 'grid' | 'table'
|
||
type InspectorTab = 'shot' | 'assets' | 'prompt' | 'output'
|
||
/** 数字框在编辑中可能是空串或被划成小数点,落库前一律过 numOr / intOrNull */
|
||
type NumField = number | string
|
||
|
||
/**
|
||
* 镜头状态筛选项同样取后端枚举(ShotStatus.ALL):之前按「当前数据里出现过的状态」生成,
|
||
* 既会随列表变动,兜底数组还漏了 draft / retrying —— 状态在表里能看到,筛选里却选不到。
|
||
*/
|
||
const SHOT_STATUS_FALLBACK = ['draft', 'ready', 'queued', 'running', 'retrying', 'generated',
|
||
'qc_passed', 'approved', 'rejected', 'failed']
|
||
|
||
/** 逐句台词:一镜多人对白时「一个台词框 + 一个说话人」不够用,
|
||
* 平台配音只能用一个嗓子念完整段,字幕也不知道每句是谁说的。 */
|
||
type DialogueLine = { character_id: number | null; name: string; text: string }
|
||
/** 镜头音效:素材引用 + 入点/时长/音量,path 是入库时的快照,素材被换也仍能复现 */
|
||
type SfxRow = Record<string, any>
|
||
|
||
const EMPTY_SHOT = {
|
||
id: null as number | null, title: '', code: '', synopsis: '', description: '',
|
||
shot_size: 'medium', camera_angle: 'eye_level', camera_movement: 'static', lens_note: '',
|
||
duration: 5 as NumField, transition_out: 'cut', transition_duration_ms: 500 as NumField, style_note: '',
|
||
dialogue: '', subtitle_text: '', subtitle_enabled: true,
|
||
lines: [] as DialogueLine[],
|
||
ambience: '', sound_effects: [] as SfxRow[],
|
||
speaker_character_id: null as number | null, voice_asset_id: null as number | null,
|
||
provider: '', model: '', mode: 'i2v', seed: '' as NumField
|
||
}
|
||
type ShotDraft = typeof EMPTY_SHOT
|
||
|
||
const EMPTY_BINDING = {
|
||
character_ids: [] as number[], scene_ids: [] as number[],
|
||
speaker_character_id: null as number | null, voice_asset_id: null as number | null
|
||
}
|
||
const EMPTY_PROMPT = { prompt: '', negative_prompt: '', reason: '', auto_sync: true }
|
||
/** 统一改参数:留空/为 null 的字段不下发,「不改」和「改成空」是两回事 */
|
||
const EMPTY_BULK = { mode: '', duration: null as number | null, transition_out: '', shot_size: '' }
|
||
const EMPTY_SCRIPT = { script_text: '', default_duration: 5, replace: false, keep_existing: true }
|
||
const EMPTY_KEYFRAME = {
|
||
model_id: null as number | null, prompt: '', negative_prompt: '',
|
||
width: 720, height: 1280, seed: null as number | null, reference_asset_ids: [] as number[]
|
||
}
|
||
|
||
/* ── 皮肤常量 ─────────────────────────────────────────────────────────────
|
||
看板卡片和分镜表是同一个镜头的两种画法,选中/拖拽/勾选三态必须一模一样,
|
||
否则换视图会让人怀疑「是不是选中丢了」。 */
|
||
|
||
/** 看板卡(.card):整张卡就是镜头入口,勾选框与缩略图预览各自拦截点击 */
|
||
const SHOT_CARD = 'flex min-w-0 cursor-pointer flex-col overflow-hidden rounded-lg border border-fill bg-bg-container '
|
||
+ 'transition-[border-color,transform,box-shadow] hover:-translate-y-px hover:border-border'
|
||
/** 缩略图(.thumb):16/9 定高,底部 3px 灯带 = 这一镜需不需要人看 */
|
||
const SHOT_THUMB = 'relative aspect-video overflow-hidden bg-bg-layout [&_img]:block [&_img]:h-full [&_img]:w-full [&_img]:object-cover [&_video]:block [&_video]:h-full [&_video]:w-full [&_video]:object-cover'
|
||
const THUMB_PLATE = 'absolute grid place-items-center text-xs tracking-wide text-text-quaternary inset-0'
|
||
const THUMB_ORDINAL = 'absolute top-[7px] left-7 grid place-items-center rounded-sm bg-bg-mask px-2 py-1 '
|
||
+ 'text-xs font-bold leading-none tracking-wide text-primary'
|
||
const THUMB_DUR = 'absolute top-[7px] right-[34px] rounded-sm bg-bg-mask px-1 py-1 '
|
||
+ 'text-xs leading-none text-text-secondary'
|
||
/** 卡片正文(.cardbody):说明两行截断,脚注靠 mt-auto 永远贴底对齐 */
|
||
const SHOT_BODY = 'flex min-w-0 flex-1 flex-col gap-2 pt-3 pr-3 pb-3 pl-3'
|
||
// 元信息行是卡片里最挤的一行,标签整排降到 sm 档;组内间距与 TagGroup 同规格(6px),
|
||
// 不再用页面临时抄的 5px。档位挂在容器上,行里新增标签不用再记一遍尺寸。
|
||
const SHOT_META = cn('flex flex-wrap items-center gap-2 text-xs text-text-quaternary', TAG_DENSE)
|
||
const SHOT_FOOT = 'mt-auto flex items-center gap-1 pt-1'
|
||
/** 预检阻塞条(.issues):左侧一道红线,比整块涂红省注意力 */
|
||
const SHOT_ISSUES = 'flex flex-col gap-0.5 rounded-md border-l-2 border-error-border bg-bg-container px-2 py-1 '
|
||
+ '[&_span]:text-xs [&_span]:leading-normal'
|
||
|
||
/** 一句一行(.linedlg-row):行号 / 说话人 / 台词 / 删除,控件在一条中心线上 */
|
||
const LINE_ROW = 'grid grid-cols-[22px_128px_minmax(0,1fr)_var(--ant-control-height)] items-center gap-2 '
|
||
+ '[&_input]:w-full [&_textarea]:w-full'
|
||
/** 音效行:素材 / 入点 / 音量 / 删除 */
|
||
const SFX_ROW = 'grid grid-cols-[minmax(0,1fr)_84px_74px_var(--ant-control-height)] items-center gap-2 '
|
||
+ '[&_input]:w-full'
|
||
const LINE_EMPTY = 'rounded-lg border border-dashed border-border bg-bg-container px-3 py-1 '
|
||
+ 'text-xs leading-relaxed text-text-quaternary'
|
||
|
||
/** 表格里那枚缩略图(.tthumb):高度由 92px 宽的画面比例决定,不是一档一档的表单控件 */
|
||
|
||
const TABLE_THUMB = 'grid w-[92px] place-items-center text-text-quaternary min-h-[34px]'
|
||
|
||
/**
|
||
* 脚本导入的「解析结果」表(列定义在模块层,页面里只留数据源)。
|
||
* 这些列不依赖组件状态,放在 render 里会让每次重渲染都重建一遍数组。
|
||
*/
|
||
const PREVIEW_COLS: Columns<any> = [
|
||
{ title: '#', width: 56, className: MUTED_MONO, render: (_: any, s: any, i: number) => s.order_index ?? i + 1 },
|
||
{ title: '标题', className: cellWrap, render: (_: any, s: any) => s.title },
|
||
{ title: '画面', className: cn(cellWrap, MUTED), render: (_: any, s: any) => s.description },
|
||
{ title: '景别/运镜', width: 150, className: MUTED,
|
||
render: (_: any, s: any) => `${opt('shot_size', s.shot_size)} · ${opt('camera_movement', s.camera_movement)}` },
|
||
{ title: '时长', width: 72, align: 'right', className: MUTED_MONO, render: (_: any, s: any) => `${s.duration}s` },
|
||
{ title: '台词 / 说话人', className: cellWrap, render: (_: any, s: any) => (
|
||
<>
|
||
{s.dialogue || '—'}
|
||
{s.speaker ? <span className={MUTED}> / {s.speaker}</span> : null}
|
||
</>) },
|
||
{ title: '角色 · 场景', className: cn(cellWrap, MUTED),
|
||
render: (_: any, s: any) => `${(s.characters || []).join('、') || '—'} · ${s.scene || '—'}` },
|
||
{ title: '关键帧', width: 150, className: MUTED_MONO,
|
||
render: (_: any, s: any) => (s.images || []).join(', ') || '—' },
|
||
{ title: '动作', width: 118, render: (_: any, s: any) => (
|
||
<Tag tone={s.will_create ? 'ok' : 'warn'}>{s.skipped_reason || (s.will_create ? '将新建' : '跳过')}</Tag>) }
|
||
]
|
||
|
||
/* ── 纯函数 ─────────────────────────────────────────────────────────────── */
|
||
|
||
/** 数字输入清空后是 '',直接 PATCH 会被后端 422 拒掉,这里统一归一成 null / 默认值 */
|
||
function numOr(value: any, fallback: number | null = null) {
|
||
if (value === '' || value === null || value === undefined) return fallback
|
||
const n = Number(value)
|
||
return Number.isFinite(n) ? n : fallback
|
||
}
|
||
function intOrNull(value: any) {
|
||
if (value === '' || value === null || value === undefined) return null
|
||
const n = parseInt(String(value), 10)
|
||
return Number.isFinite(n) ? n : null
|
||
}
|
||
|
||
function isImageAsset(asset: any) {
|
||
return /\.(png|jpe?g|webp|gif|bmp|tiff?)$/i.test(asset?.path || asset?.url || '')
|
||
|| (!!asset?.width && !asset?.duration_ms)
|
||
}
|
||
|
||
/** 后端可能只给了 dialogue + speaker(老数据),这里折算成一行,编辑器永远只看 lines */
|
||
function normalizeLines(full: any): DialogueLine[] {
|
||
const rows: DialogueLine[] = (Array.isArray(full?.lines) ? full.lines : []).map((raw: any) => (
|
||
typeof raw === 'string'
|
||
? { character_id: full?.speaker_character_id ?? null, name: '', text: String(raw || '').trim() }
|
||
: { character_id: raw?.character_id ?? null, name: String(raw?.name || ''), text: String(raw?.text || '').trim() }
|
||
)).filter((row) => row.text)
|
||
if (rows.length) return rows
|
||
const text = String(full?.dialogue || '').trim()
|
||
return text ? [{ character_id: full?.speaker_character_id ?? null,
|
||
name: String(full?.speaker_name || ''), text }] : []
|
||
}
|
||
|
||
/** 关键帧默认画布:跟住项目档位,竖屏项目不会生成一张横的塞进首帧 */
|
||
function keyframeCanvas(resolution?: string, aspectRatio?: string): [number, number] {
|
||
return canvasFor(String(resolution || '1080p'), String(aspectRatio || '16:9'), 1536)
|
||
}
|
||
|
||
/**
|
||
* 自动生成参考图(最多 4 张):场景图 → 人物定妆图 → 本镜参考图。
|
||
* 排序就是优先级——模型只吃前几张参考图时,喂进去的必须是决定画面一致性那几张。
|
||
*/
|
||
function autoShotReferenceIds(shot: any, characters: any[], scenes: any[]) {
|
||
const ids: number[] = []
|
||
const add = (asset: any) => {
|
||
if (asset?.id && isImageAsset(asset) && ids.length < 4) ids.push(asset.id)
|
||
}
|
||
for (const scene of shot.scenes || []) {
|
||
const owner = scenes.find((row) => row.id === scene.id)
|
||
const assets = [...(owner?.assets || [])].sort((a, b) => {
|
||
if (a.kind === 'scene_image' && b.kind !== 'scene_image') return -1
|
||
if (b.kind === 'scene_image' && a.kind !== 'scene_image') return 1
|
||
return Number(b.id) - Number(a.id)
|
||
})
|
||
add(assets[0])
|
||
}
|
||
for (const character of shot.characters || []) {
|
||
const owner = characters.find((row) => row.id === character.id)
|
||
const assets = [...(owner?.assets || [])].sort((a, b) => {
|
||
const rank: Record<string, number> = { portrait: 0, turnaround: 1, costume: 2, expression: 3 }
|
||
return (rank[a.kind] ?? 9) - (rank[b.kind] ?? 9)
|
||
})
|
||
add(assets[0])
|
||
}
|
||
for (const asset of (shot.assets || []).filter((row: any) => row.kind === 'reference_image')) add(asset)
|
||
return [...new Set(ids)].slice(0, 4)
|
||
}
|
||
|
||
/**
|
||
* 一屏镜头展开成预览队列:**一镜一条**,同镜的产物挂在 `peers` 上由预览器顶部切换。
|
||
* 以前每镜入队 4 条(关键帧→审片预览→生成视频→配音),从分镜点开一镜后
|
||
* 按 → 去的是「这一镜的下一个产物」或「上一镜的配音」,而不是下一镜——
|
||
* 审片时手指连按方向键,翻半天还在同一镜里打转。
|
||
*/
|
||
function shotMediaQueue(list: any[], focus?: { shot: any; which: string }): MediaItem[] {
|
||
const queue: MediaItem[] = []
|
||
const seen = new Set<number>()
|
||
for (const shot of list) {
|
||
// 检查器里那一镜和列表里是同一个对象,source 会把它列两次;
|
||
// 一镜一格之后重复列就是「按 → 原地不动」,按镜头号去过重。
|
||
if (seen.has(shot.id)) continue
|
||
seen.add(shot.id)
|
||
const which = focus && shot.id === focus.shot.id ? focus.which : 'output'
|
||
const item = fromShotGroup(shot, which as any)
|
||
if (item) queue.push(item)
|
||
}
|
||
return queue
|
||
}
|
||
|
||
/**
|
||
* 「到调度中心生成这一镜」的落点。
|
||
* 已经有产物的镜头必须带 force=1:后端把「产物已存在 / 已审核合格」判成 skip,
|
||
* 调度中心又不让勾选 skip 行,用户从这儿跳过去就是**单个镜头无法重新生成**。
|
||
*/
|
||
const dispatchLink = (projectId: any, shot: any) =>
|
||
`/projects/${projectId}/dispatch?shot=${shot?.id}${shot?.output_url ? '&force=1' : ''}`
|
||
|
||
/** 当前在产物页签听的到底是哪一条:默认审片预览(平台配音),手动切到模型原声时跟着切 */
|
||
const shotOutputWhich = (d: any, prefer: boolean) => ((d?.preview_ready && prefer) ? 'preview' : 'output')
|
||
|
||
const issueOf = (shot: any, severity: string) => (shot.issues || []).filter((i: any) => i.severity === severity)
|
||
|
||
/** 卡片灯带:失败/阻塞红、已合格绿、在跑蓝,其余不亮(不该为「还没轮到」上色)。
|
||
口径与 PipelineConsole / <Tag> 对齐:完成态走 success 绿,进行/排队走主色蓝
|
||
(antd 的 processing 本来就是主色)。上一版是「已合格=主色、在跑=绿」,
|
||
那套只有配柠檬绿品牌时才讲得通;换成标准蓝以后,绿=完成、蓝=进行,
|
||
和「蓝=可点」也不打架,不必再借一档绿松。 */
|
||
function cardPulse(shot: any) {
|
||
if (shot.status === 'failed' || issueOf(shot, 'error').length) return 'bad'
|
||
if (shot.status === 'approved') return 'ok'
|
||
if (['running', 'queued', 'retrying', 'generated', 'qc_passed'].includes(shot.status)) return 'run'
|
||
return ''
|
||
}
|
||
const PULSE_CLS: Record<string, string> = {
|
||
ok: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-success',
|
||
bad: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-error',
|
||
run: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-primary'
|
||
}
|
||
|
||
/** 导出这一屏的三种格式(后端按 fmt 生成附件) */
|
||
const exportHref = (projectId: any, fmt: string) => api.href(`/api/projects/${projectId}/shots/export`, { fmt })
|
||
|
||
export default function Storyboard() {
|
||
const projectId = useProjectStore((s) => s.id)
|
||
const project = useProjectStore((s) => s.project)
|
||
const meta = useSystemStore((s) => s.meta)
|
||
const registryRows = useModelsStore((s) => s.rows)
|
||
const registryError = useModelsStore((s) => s.error)
|
||
const previewIsOpen = usePreviewOpen()
|
||
const [params, setParams] = useSearchParams()
|
||
|
||
const [error, setError] = useState('')
|
||
const [notice, setNotice] = useState('')
|
||
const [busy, setBusy] = useState('')
|
||
const [loading, setLoading] = useState(true)
|
||
const [shots, setShots] = useState<any[]>([])
|
||
const [plannedDuration, setPlannedDuration] = useState(0)
|
||
|
||
/* ---------- 视图状态 ---------- */
|
||
const [view, setView] = useLocalStorage<ViewMode>('nex.sb.view', 'grid')
|
||
const [keyword, setKeyword] = useState('')
|
||
const [statusFilter, setStatusFilter] = useState('')
|
||
const [modeFilter, setModeFilter] = useState('')
|
||
const [issueOnly, setIssueOnly] = useState(false)
|
||
const [noKeyframeOnly, setNoKeyframeOnly] = useState(false)
|
||
const [sortKey, setSortKey] = useState<'order' | 'status' | 'duration'>('order')
|
||
|
||
const [selectedId, setSelectedId] = useState<number | null>(null)
|
||
const [checked, setChecked] = useState<Set<number>>(() => new Set())
|
||
const [detail, setDetail] = useState<any>(null)
|
||
const [revisions, setRevisions] = useState<any[]>([])
|
||
const [inspectorTab, setInspectorTab] = useState<InspectorTab>('shot')
|
||
const [showImport, setShowImport] = useState(false)
|
||
const [creating, setCreating] = useState(false)
|
||
/** 审片预览:画面沿用模型产物,声音换成平台配音(默认播放这条,避免把模型原声误判成配音错误) */
|
||
const [preferVoiceoverAudio, setPreferVoiceoverAudio] = useState(true)
|
||
|
||
const [draft, setDraft] = useState<ShotDraft>({ ...EMPTY_SHOT })
|
||
const [dirty, setDirty] = useState(false)
|
||
const [binding, setBinding] = useState({ ...EMPTY_BINDING })
|
||
const [promptForm, setPromptForm] = useState({ ...EMPTY_PROMPT })
|
||
const [bulk, setBulk] = useState({ open: false, fields: { ...EMPTY_BULK } })
|
||
|
||
/* ---------- 导入 ---------- */
|
||
const [importMode, setImportMode] = useState<'paste' | 'file'>('paste')
|
||
const [script, setScript] = useState({ ...EMPTY_SCRIPT })
|
||
const [scriptFile, setScriptFile] = useState<File | null>(null)
|
||
const [imageFiles, setImageFiles] = useState<File[]>([])
|
||
const [preview, setPreview] = useState<any>(null)
|
||
const [sfxAssets, setSfxAssets] = useState<any[]>([])
|
||
const [keyframeGen, setKeyframeGen] = useState({ ...EMPTY_KEYFRAME })
|
||
|
||
const characters: any[] = project?.characters || []
|
||
const scenes: any[] = project?.scenes || []
|
||
const voices: any[] = project?.voices || []
|
||
|
||
/* 模型注册表是异步加载的全局单例:订阅 rows 再派生,
|
||
否则页面拿到的是「加载前」的空数组,图像模型下拉永远选不出东西。 */
|
||
const imageProviders = useMemo(
|
||
() => modelsOf('image', false).filter((row) => row.available !== false),
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
[registryRows]
|
||
)
|
||
const videoModels = useMemo(
|
||
() => modelsOf('video'),
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
[registryRows]
|
||
)
|
||
const keyframeModel = useMemo(
|
||
() => imageProviders.find((p) => p.id === keyframeGen.model_id) || defaultFor('image', false),
|
||
[imageProviders, keyframeGen.model_id]
|
||
)
|
||
|
||
/* ---------- 镜头模型覆盖:取值全部来自模型注册表 ---------- */
|
||
/** 覆盖引用 provider|model;留空表示跟随项目默认 */
|
||
const modelRef = draft.provider ? `${draft.provider}|${draft.model || ''}` : ''
|
||
const shotModelRow = findByPair(draft.provider, draft.model) || projectVideoModel(project)
|
||
const shotCaps = capsOf(shotModelRow?.provider, shotModelRow?.model)
|
||
/** 放大交付档(模型原生出片 + 合成端放大):只在确实存在时提示,别把正常链路说成缺陷 */
|
||
const shotUpscaleTiers = shotCaps.upscaleTo.filter((v) => !shotCaps.resolutions.includes(v))
|
||
/** 生成模式只能选模型声明支持的 */
|
||
const modeOptions = useMemo(() => {
|
||
const all = options('mode')
|
||
return shotCaps.modes.length ? all.filter((o) => shotCaps.modes.includes(o.value)) : all
|
||
}, [shotCaps.modes])
|
||
const modelKnown = !!shotCaps.known
|
||
const durationRange = (() => {
|
||
const { minDuration, maxDuration } = shotCaps
|
||
if (!minDuration && !maxDuration) return ''
|
||
if (minDuration && maxDuration) return `${minDuration} – ${maxDuration} 秒`
|
||
return minDuration ? `≥ ${minDuration} 秒` : `≤ ${maxDuration} 秒`
|
||
})()
|
||
|
||
/** 模型覆盖下拉的候选:跟随项目 + 注册表里的视频模型 + 已失效的当前值。
|
||
「已失效」那条必须留着:注册表查不到时如果直接吞掉选项,下拉会显示成空白,
|
||
用户看不出是自己填错了模型,只会以为「选了又没选上」。 */
|
||
const modelChoices = useMemo(() => [
|
||
{ value: '', label: `跟随项目:${project?.default_provider || '-'}/${project?.default_model || '-'}` },
|
||
...videoModels.map((m: any) => ({
|
||
value: `${m.provider}|${m.model}`,
|
||
label: `${m.display_name || `${m.provider}/${m.model}`}${m.available ? '' : '(未就绪)'}`
|
||
})),
|
||
...(draft.provider && !modelKnown
|
||
? [{ value: `${draft.provider}|${draft.model || ''}`, label: `已失效:${draft.provider}/${draft.model}(不在注册表)` }]
|
||
: [])
|
||
], [project, videoModels, draft.provider, draft.model, modelKnown])
|
||
|
||
/** 与项目档位叠加后的能力提示:写进去但模型不支持的组合,派发时必然报错 */
|
||
const shotWarnings = (() => {
|
||
const warn: string[] = []
|
||
if (!modelKnown) {
|
||
if (draft.provider) warn.push(`覆盖的 ${draft.provider}/${draft.model} 不在模型注册表里,保存后派发会失败。`)
|
||
else warn.push('模型注册表尚未就绪,能力校验暂不可用。')
|
||
return warn
|
||
}
|
||
const caps = shotCaps
|
||
if (caps.mock) warn.push('本镜指定了演练通道,只产出占位视频。')
|
||
const d = Number(draft.duration)
|
||
if (caps.minDuration && d && d < caps.minDuration) warn.push(`时长 ${d}s 低于模型下限 ${caps.minDuration}s,已按 ${caps.minDuration}s 校正。`)
|
||
if (caps.maxDuration && d && d > caps.maxDuration) warn.push(`时长 ${d}s 超出模型上限 ${caps.maxDuration}s,已按 ${caps.maxDuration}s 校正。`)
|
||
const res = String(project?.resolution || '')
|
||
const deliverable = [...new Set([...caps.resolutions, ...caps.upscaleTo])]
|
||
if (deliverable.length && res && !deliverable.includes(res)) {
|
||
warn.push(`本镜模型只支持 ${deliverable.join(' / ')},项目当前是 ${res}。`)
|
||
} else if (res && caps.upscaleTo.includes(res) && !caps.resolutions.includes(res)) {
|
||
warn.push(`本镜模型原生只到 ${caps.resolutions[caps.resolutions.length - 1] || '低档'},`
|
||
+ `${res} 由合成端放大交付(卡时不变,画质介于两者之间)。`)
|
||
}
|
||
if (caps.modes.length && draft.mode && !caps.modes.includes(draft.mode)) {
|
||
warn.push(`模型不支持 ${draft.mode} 模式,可用 ${caps.modes.join(' / ')}。`)
|
||
}
|
||
return warn
|
||
})()
|
||
|
||
/** 关键帧可选的参考图:人物 / 场景母版 + 这一镜已上传的图,按 id 去重并标出来自谁 */
|
||
const imageReferences = useMemo(() => {
|
||
const rows = new Map<number, any>()
|
||
for (const character of characters) {
|
||
for (const asset of character.assets || []) {
|
||
if (isImageAsset(asset)) rows.set(asset.id, { ...asset, owner_label: character.name })
|
||
}
|
||
}
|
||
for (const scene of scenes) {
|
||
for (const asset of scene.assets || []) {
|
||
if (isImageAsset(asset)) rows.set(asset.id, { ...asset, owner_label: scene.name })
|
||
}
|
||
}
|
||
for (const asset of detail?.assets || []) {
|
||
if (isImageAsset(asset)) rows.set(asset.id, { ...asset, owner_label: '当前镜头' })
|
||
}
|
||
return [...rows.values()]
|
||
}, [characters, scenes, detail])
|
||
|
||
const current = shots.find((s) => s.id === selectedId) || null
|
||
const issueCount = shots.filter((s) => !s.ready).length
|
||
const approvedCount = shots.filter((s) => s.status === 'approved').length
|
||
|
||
const filtered = useMemo(() => {
|
||
const q = keyword.trim().toLowerCase()
|
||
let list = shots.filter((s) => {
|
||
if (statusFilter && s.status !== statusFilter) return false
|
||
if (modeFilter && s.mode !== modeFilter) return false
|
||
if (issueOnly && s.ready) return false
|
||
if (noKeyframeOnly && s.keyframe_url) return false
|
||
if (!q) return true
|
||
return `${s.code} ${s.title} ${s.description} ${s.dialogue} ${(s.characters || []).map((c: any) => c.name).join(' ')} ${(s.scenes || []).map((c: any) => c.name).join(' ')}`
|
||
.toLowerCase().includes(q)
|
||
})
|
||
if (sortKey === 'status') list = [...list].sort((a, b) => a.status.localeCompare(b.status))
|
||
if (sortKey === 'duration') list = [...list].sort((a, b) => (b.duration || 0) - (a.duration || 0))
|
||
return list
|
||
}, [shots, keyword, statusFilter, modeFilter, issueOnly, noKeyframeOnly, sortKey])
|
||
|
||
/* ---------- 逐镜导航(检查器头部按钮 = J/K = 点卡片,同一份顺序)---------- */
|
||
const shotIndex = filtered.findIndex((s) => s.id === selectedId)
|
||
const canStep = (delta: number) => shotIndex >= 0
|
||
&& shotIndex + delta >= 0 && shotIndex + delta < filtered.length
|
||
|
||
const shotVideoSrc = (preferVoiceoverAudio && detail?.preview_url)
|
||
? detail.preview_url : (detail?.output_url || '')
|
||
|
||
/** 拖拽改镜序的两个临时态:只影响边框配色,不该进任何表单脏值判断 */
|
||
const [dragging, setDragging] = useState<number | null>(null)
|
||
const [dragOver, setDragOver] = useState<number | null>(null)
|
||
|
||
/* ---------- 异步回调读状态:过一层 ref ----------
|
||
Vue 的 ref 在回调里读到的永远是当前值,React 的 useState 会被闭包冻结在「渲染时」。
|
||
这里镜像出来的几个值都是**回调里读了要出事**的:load() 拿 selectedId 判断
|
||
「选中的镜头还在不在」、拿 showImport/creating 判断「要不要自动弹导入面板」,
|
||
自动刷新每 10 秒跑一次,读到旧值就会把刚点开的检查器关掉。 */
|
||
const live = useRef({
|
||
selectedId, dirty, creating, showImport, loading, shots, filtered, params, previewIsOpen
|
||
})
|
||
live.current = {
|
||
selectedId, dirty, creating, showImport, loading, shots, filtered, params, previewIsOpen
|
||
}
|
||
|
||
const shotPos = shotIndex + 1
|
||
/** 镜头素材队列:母版素材自带 versions,全局预览器里可直接切历史版本 */
|
||
const assetQueue = useMemo(
|
||
() => (detail?.assets || []).map((a: any) => fromAsset(a)).filter(Boolean) as MediaItem[],
|
||
[detail]
|
||
)
|
||
|
||
/* ---------- 编辑态:草稿 / 绑定 / 提示词三份表单 ---------- */
|
||
/** 任何草稿字段改动都要同时置脏,否则「放弃修改」和切镜确认都会失灵 */
|
||
function edit(patch: Partial<ShotDraft>) {
|
||
setDraft((prev) => ({ ...prev, ...patch }))
|
||
setDirty(true)
|
||
}
|
||
/** 资产绑定同样是「这一镜的设定」,改了不保存一样会丢 */
|
||
function patchBinding(patch: Partial<typeof EMPTY_BINDING>) {
|
||
setBinding((prev) => ({ ...prev, ...patch }))
|
||
setDirty(true)
|
||
}
|
||
/** 提示词走独立的版本接口,不进镜头草稿的脏值判断(它有自己的一套保存/回滚) */
|
||
function patchPrompt(patch: Partial<typeof EMPTY_PROMPT>) {
|
||
setPromptForm((prev) => ({ ...prev, ...patch }))
|
||
}
|
||
|
||
/** 模型覆盖:换模型时顺手把模式与时长夹回模型支持的区间,省得每次都要人工纠错 */
|
||
function setModelRef(value: string) {
|
||
const [provider, model] = parseRef(value)
|
||
const caps = capsOf(provider, model)
|
||
setDraft((prev) => {
|
||
const next = { ...prev, provider, model }
|
||
if (caps.modes.length && !caps.modes.includes(next.mode)) next.mode = caps.modes[0]
|
||
if (caps.maxDuration > 0 && Number(next.duration) > caps.maxDuration) next.duration = caps.maxDuration
|
||
if (caps.minDuration > 0 && Number(next.duration) < caps.minDuration) next.duration = caps.minDuration
|
||
return next
|
||
})
|
||
setDirty(true)
|
||
}
|
||
|
||
function defaultImageProvider() {
|
||
return imageProviders.find((p) => p.is_default && p.available)
|
||
|| imageProviders.find((p) => p.available)
|
||
|| imageProviders[0]
|
||
}
|
||
|
||
/** 关键帧生成台的初值:提示词抄本镜、尺寸跟项目档位、参考图按「场景→人物→本镜」自动挑 */
|
||
function syncKeyframeDraft(shot: any) {
|
||
const [width, height] = keyframeCanvas(project?.resolution, project?.aspect_ratio)
|
||
setKeyframeGen((prev) => ({
|
||
...prev,
|
||
model_id: keyframeModel?.id || prev.model_id,
|
||
prompt: shot?.prompt || shot?.description || '',
|
||
negative_prompt: shot?.negative_prompt || '',
|
||
width,
|
||
height,
|
||
seed: null,
|
||
reference_asset_ids: autoShotReferenceIds(shot || {}, characters, scenes),
|
||
}))
|
||
}
|
||
|
||
/* ---------- 数据加载 ---------- */
|
||
async function load(keepScroll = true) {
|
||
if (!projectId) return
|
||
const anchor = keepScroll ? window.scrollY : 0
|
||
setBusy(live.current.loading ? '' : '刷新分镜')
|
||
try {
|
||
const data = await api.get(`/api/projects/${projectId}/shots/board`)
|
||
const rows: any[] = data.shots || []
|
||
setShots(rows)
|
||
setPlannedDuration(Number(data.planned_duration || 0))
|
||
setError('')
|
||
const want = Number(live.current.params.get('shot') || 0)
|
||
const selected = live.current.selectedId
|
||
if (want && rows.some((s) => s.id === want)) await select(want, false)
|
||
else if (selected && !rows.some((s) => s.id === selected)) await closeInspector()
|
||
else if (selected) await select(selected, false)
|
||
// 空项目第一眼就该看到「怎么把脚本变成镜头」,而不是一个空框
|
||
if (!rows.length && !live.current.showImport && !live.current.creating) setShowImport(true)
|
||
} catch (exc: any) { setError(exc.message) }
|
||
finally {
|
||
setLoading(false)
|
||
setBusy('')
|
||
if (keepScroll) {
|
||
// 列表重排会在下一帧才落到版面上,滚动位置必须等那一帧画完再还回去
|
||
requestAnimationFrame(() => window.scrollTo(0, anchor))
|
||
}
|
||
}
|
||
}
|
||
|
||
async function run(label: string, fn: () => Promise<any>): Promise<boolean> {
|
||
setBusy(label)
|
||
setError('')
|
||
try { await fn(); await load(); await refresh(); return true }
|
||
catch (exc: any) { setError(exc.message); return false }
|
||
finally { setBusy('') }
|
||
}
|
||
|
||
/* ---------- 选中 / 检查器 ---------- */
|
||
async function select(id: number, syncUrl = true) {
|
||
if (!id) return
|
||
/* 未保存修改的三道闸(切换 / 关闭 / 新增)走站内确认框:问话只留一句,
|
||
后果写进 desc,主按钮把要做的动作写出来(R19)。 */
|
||
if (id !== live.current.selectedId && live.current.dirty) {
|
||
const ok = await confirmAction({
|
||
title: '切换到别的镜头?',
|
||
desc: '当前镜头有未保存的修改,切换后这些修改会丢失。',
|
||
tone: 'warn', confirmText: '继续切换'
|
||
})
|
||
if (!ok) return
|
||
}
|
||
if (syncUrl && id !== live.current.selectedId) {
|
||
setParams((prev) => {
|
||
const next = new URLSearchParams(prev)
|
||
next.set('shot', String(id))
|
||
return next
|
||
}, { replace: true })
|
||
}
|
||
setSelectedId(id)
|
||
setDirty(false)
|
||
if (id) scrollToInspector()
|
||
try {
|
||
const data = await api.get(`/api/projects/${projectId}/shots/${id}`)
|
||
const full = data.shot || {}
|
||
setDetail(full)
|
||
/* EMPTY_SHOT 是模块级常量,摊进草稿时必须把两个数组换成新实例:
|
||
浅拷贝会让「+ 再加一句」把行写进常量本身,下一镜就带着残行开始。 */
|
||
const next: ShotDraft = { ...EMPTY_SHOT, lines: [], sound_effects: [] }
|
||
for (const key of Object.keys(EMPTY_SHOT) as (keyof ShotDraft)[]) {
|
||
const value = (full as any)[key]
|
||
if (value !== undefined && value !== null) (next as any)[key] = value
|
||
}
|
||
// seed 必须回落到空串而不是 null:`<input type=number value={null}>` 会让 React 报警,
|
||
// 并把输入框切成非受控(下一镜会带着上一镜留在 DOM 里的值);保存时 intOrNull('') 同样得到 null。
|
||
next.seed = full.seed ?? ''
|
||
next.lines = normalizeLines(full)
|
||
next.ambience = full.ambience || ''
|
||
next.sound_effects = (Array.isArray(full.sound_effects) ? full.sound_effects : [])
|
||
.map((row: any) => ({ ...row }))
|
||
setDraft(next)
|
||
setBinding({
|
||
character_ids: (full.characters || []).map((c: any) => c.id),
|
||
scene_ids: (full.scenes || []).map((s: any) => s.id),
|
||
speaker_character_id: full.speaker_character_id ?? null,
|
||
voice_asset_id: full.voice_asset_id ?? null
|
||
})
|
||
setPromptForm({
|
||
prompt: full.prompt || '',
|
||
negative_prompt: full.negative_prompt || '',
|
||
reason: '',
|
||
auto_sync: !full.prompt_overridden && !(full.params || {}).prompt_override
|
||
})
|
||
syncKeyframeDraft(full)
|
||
setRevisions((await api.get(`/api/projects/${projectId}/shots/${id}/prompt-revisions`)
|
||
.catch(() => ({ revisions: [] })))?.revisions || [])
|
||
} catch (exc: any) { setError(exc.message) }
|
||
}
|
||
|
||
async function goShot(delta: number) {
|
||
const row = live.current.filtered[shotIndex + delta]
|
||
if (row) await select(row.id)
|
||
}
|
||
|
||
/* 检查器本体与「画面描述」的 DOM 句柄。旧站靠 document.querySelector('.sb-insp')
|
||
跨组件摸元素,类名换成工具类之后那个钩子就不存在了——「✎ 改文案」点了不聚焦,
|
||
属于静默失效(querySelector 返回 null 谁都不报错)。ref 挂在节点上,
|
||
与样式类名彻底脱钩,改皮肤不会再弄丢行为。 */
|
||
const inspRef = useRef<HTMLElement>(null)
|
||
const descRef = useRef<HTMLTextAreaElement>(null)
|
||
|
||
/** 窄屏时检查器堆在看板上方,选中镜头后把它滚进视野,避免"点了没反应"的错觉 */
|
||
function scrollToInspector() {
|
||
if (!window.matchMedia('(max-width: 1080px)').matches) return
|
||
requestAnimationFrame(() => {
|
||
inspRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||
})
|
||
}
|
||
|
||
async function closeInspector() {
|
||
if (live.current.dirty) {
|
||
const ok = await confirmAction({
|
||
title: '关闭分镜详情?',
|
||
desc: '当前镜头有未保存的修改,关闭后这些修改会丢失。',
|
||
tone: 'warn', confirmText: '仍然关闭', confirmIcon: <IconClose />
|
||
})
|
||
if (!ok) return false
|
||
}
|
||
setSelectedId(null)
|
||
setDetail(null)
|
||
setDirty(false)
|
||
setParams((prev) => {
|
||
const next = new URLSearchParams(prev)
|
||
next.delete('shot')
|
||
return next
|
||
}, { replace: true })
|
||
return true
|
||
}
|
||
|
||
/** 新增态的空表单:数组每次都要新建(同上,浅拷贝会污染 EMPTY_SHOT) */
|
||
function seedEmptyShot() {
|
||
setDraft({ ...EMPTY_SHOT, lines: [], sound_effects: [] })
|
||
setBinding({ ...EMPTY_BINDING, character_ids: [], scene_ids: [] })
|
||
}
|
||
|
||
async function startCreate() {
|
||
if (live.current.dirty) {
|
||
const ok = await confirmAction({
|
||
title: '新增一个镜头?',
|
||
desc: '当前镜头有未保存的修改,新增镜头会丢掉这些修改。',
|
||
tone: 'warn', confirmText: '继续新增', confirmIcon: <IconAdd />
|
||
})
|
||
if (!ok) return
|
||
}
|
||
setCreating(true)
|
||
setSelectedId(null)
|
||
setDetail(null)
|
||
setInspectorTab('shot')
|
||
seedEmptyShot()
|
||
setDirty(false)
|
||
setShowImport(false)
|
||
}
|
||
|
||
/** 放弃修改 = 编辑态用后端这份重新灌一遍(同 id 不触发切换确认),新增态清回空表 */
|
||
function resetDraft() {
|
||
const selected = live.current.selectedId
|
||
if (selected) { select(selected, false); return }
|
||
if (live.current.creating) { seedEmptyShot(); setDirty(false) }
|
||
}
|
||
|
||
/* ---------- 镜头写入 ---------- */
|
||
async function saveShot() {
|
||
if (!String(draft.title).trim() && !String(draft.description).trim()) {
|
||
setError('请填写镜头标题或画面描述'); return
|
||
}
|
||
const body: any = {
|
||
title: String(draft.title).trim(), code: String(draft.code).trim(),
|
||
synopsis: draft.synopsis, description: draft.description, style_note: draft.style_note,
|
||
shot_size: draft.shot_size, camera_angle: draft.camera_angle, camera_movement: draft.camera_movement,
|
||
lens_note: draft.lens_note, duration: numOr(draft.duration, 5),
|
||
transition_out: draft.transition_out, transition_duration_ms: numOr(draft.transition_duration_ms, 0),
|
||
dialogue: draft.dialogue, subtitle_text: draft.subtitle_text, subtitle_enabled: !!draft.subtitle_enabled,
|
||
lines: draft.lines.map((row) => ({
|
||
character_id: row.character_id ?? null, name: lineSpeakerName(row), text: String(row.text || '').trim()
|
||
})).filter((row) => row.text),
|
||
ambience: String(draft.ambience || '').trim(),
|
||
sound_effects: draft.sound_effects.filter((row: any) => row.asset_id || row.path).map((row: any) => ({
|
||
name: String(row.name || ''), asset_id: row.asset_id ?? null, path: String(row.path || ''),
|
||
offset_ms: numOr(row.offset_ms, 0), duration_ms: numOr(row.duration_ms, 3000),
|
||
gain_db: numOr(row.gain_db, -8)
|
||
})),
|
||
speaker_character_id: intOrNull(draft.speaker_character_id
|
||
?? (draft.lines.length === 1 ? draft.lines[0].character_id : null)),
|
||
voice_asset_id: intOrNull(draft.voice_asset_id),
|
||
provider: String(draft.provider).trim(), model: String(draft.model).trim(),
|
||
mode: draft.mode, seed: intOrNull(draft.seed)
|
||
}
|
||
const keepId = draft.id
|
||
const isEdit = !!draft.id && !creating
|
||
const ok = isEdit
|
||
? await run('保存镜头', () => api.patch(`/api/projects/${projectId}/shots/${draft.id}`, body))
|
||
: await run('创建镜头', () => api.post(`/api/projects/${projectId}/shots`,
|
||
{ ...body, order_index: live.current.shots.length + 1 }))
|
||
if (ok) {
|
||
setCreating(false)
|
||
setDirty(false)
|
||
setNotice(keepId ? '镜头已保存,提示词与预检已同步重算' : '镜头已创建')
|
||
// 只收回自己那条提示:中途若被别的动作改写,不能把别人的消息擦掉
|
||
window.setTimeout(() => setNotice((prev) => (prev.startsWith('镜头已') ? '' : prev)), 4000)
|
||
if (!keepId) {
|
||
const created = [...live.current.shots].sort((a, b) => b.id - a.id)[0]
|
||
if (created) await select(created.id)
|
||
}
|
||
}
|
||
}
|
||
|
||
async function saveBindings() {
|
||
const selected = live.current.selectedId
|
||
const ok = await run('保存绑定',
|
||
() => api.post(`/api/projects/${projectId}/shots/${selected}/bindings`, { ...binding }))
|
||
if (ok) notify('绑定已更新:人物 / 场景 / 说话人 / 声线,提示词已重算')
|
||
}
|
||
|
||
async function savePrompt() {
|
||
const selected = live.current.selectedId
|
||
const ok = await run('写入提示词', () => api.post(`/api/projects/${projectId}/shots/${selected}/prompt`, {
|
||
prompt: promptForm.prompt, negative_prompt: promptForm.negative_prompt,
|
||
reason: promptForm.reason || '人工修改', actor: 'studio', auto_sync: promptForm.auto_sync
|
||
}))
|
||
if (!ok) return
|
||
notify('提示词版本已保存')
|
||
setRevisions((await api.get(`/api/projects/${projectId}/shots/${selected}/prompt-revisions`)).revisions || [])
|
||
const as = await api.get(`/api/projects/${projectId}/shots/${selected}`)
|
||
setDetail(as.shot)
|
||
setPromptForm((prev) => ({ ...prev, prompt: as.shot.prompt, negative_prompt: as.shot.negative_prompt }))
|
||
}
|
||
|
||
/** 历史版本「用这条」:只填回表单,落库仍走一次写入 —— 回滚本身也要留痕 */
|
||
function useRevision(r: any) {
|
||
setPromptForm({
|
||
prompt: r.prompt, negative_prompt: r.negative_prompt,
|
||
reason: `回滚到版本 #${r.id}`, auto_sync: false
|
||
})
|
||
}
|
||
|
||
async function removeShot(shot: any) {
|
||
const ok = await confirmAction({
|
||
title: `删除镜头 #${shot.order_index}${shot.title ? ' ' + shot.title : ''}?`,
|
||
desc: '已生成的产物文件保留,但镜头关联会解除,不可恢复。',
|
||
tone: 'danger', confirmText: '删除', confirmIcon: <IconDelete />
|
||
})
|
||
if (!ok) return
|
||
if (live.current.selectedId === shot.id) {
|
||
setDirty(false)
|
||
await closeInspector()
|
||
}
|
||
await run('删除镜头', () => api.del(`/api/projects/${projectId}/shots/${shot.id}`))
|
||
}
|
||
|
||
/* ---------- 审片预览 / 关键帧 ---------- */
|
||
async function buildShotPreview(force = true) {
|
||
const d: any = detail
|
||
if (!d?.id) return
|
||
setBusy('封装审片预览')
|
||
try {
|
||
await api.post(`/api/projects/${projectId}/shots/${d.id}/preview`, { force, actor: 'studio' })
|
||
const data = await api.get(`/api/projects/${projectId}/shots/${d.id}`)
|
||
setDetail(data.shot || d)
|
||
setNotice('审片预览已就绪:画面不变,声音使用平台配音')
|
||
await load(true)
|
||
} catch (exc: any) {
|
||
setError(exc?.message || '封装审片预览失败')
|
||
} finally {
|
||
setBusy('')
|
||
}
|
||
}
|
||
|
||
async function loadProviders() {
|
||
try {
|
||
await loadModels(true)
|
||
if (registryError) setError(registryError)
|
||
setKeyframeGen((prev) => {
|
||
const picked = imageProviders.find((row) => row.id === prev.model_id)
|
||
if (prev.model_id && picked) return prev
|
||
return { ...prev, model_id: defaultImageProvider()?.id || null }
|
||
})
|
||
} catch (exc: any) {
|
||
setError(exc.message)
|
||
}
|
||
}
|
||
|
||
async function generateKeyframe() {
|
||
const selected = live.current.selectedId
|
||
if (!selected) { setError('请先选择镜头'); return }
|
||
const spec = keyframeModel
|
||
if (!spec) { setError('尚未启用真实图像模型,请先在模型管理中心配置并启用图像模型'); return }
|
||
if (!keyframeGen.prompt.trim()) { setError('关键帧提示词不能为空'); return }
|
||
setBusy(`AI 生成关键帧(${spec.display_name || spec.model})`)
|
||
setError('')
|
||
try {
|
||
const result = await api.post(`/api/projects/${projectId}/assets/generate`, {
|
||
target_type: 'shot', target_id: selected, kind: 'keyframe',
|
||
provider: spec.provider, model: spec.model,
|
||
prompt: keyframeGen.prompt.trim(), negative_prompt: keyframeGen.negative_prompt.trim(),
|
||
width: keyframeGen.width, height: keyframeGen.height, seed: keyframeGen.seed,
|
||
reference_asset_ids: keyframeGen.reference_asset_ids, drain: true,
|
||
})
|
||
const task = result.task || {}
|
||
if (task.status !== 'succeeded') throw new Error(task.error_message || task.error_code || '关键帧生成失败')
|
||
notify(`关键帧已由 ${spec.provider}/${spec.model} 生成,并登记为镜头 ${current?.order_index ?? ''} 的首帧`)
|
||
await load()
|
||
await refresh()
|
||
} catch (exc: any) {
|
||
setError(exc.message)
|
||
} finally {
|
||
setBusy('')
|
||
}
|
||
}
|
||
|
||
/* ---------- 排序 / 批量 ---------- */
|
||
function startDrag(id: number) { setDragging(id) }
|
||
function overDrag(id: number) { if (dragging !== id) setDragOver(id) }
|
||
async function dropOn(id: number) {
|
||
const from = dragging
|
||
setDragOver(null)
|
||
setDragging(null)
|
||
if (!from || from === id) return
|
||
await run('调整顺序', () => api.post(`/api/projects/${projectId}/shots/bulk`, {
|
||
action: 'move', shot_ids: [from], index: live.current.shots.findIndex((s) => s.id === id) + 1
|
||
}))
|
||
}
|
||
/** 上移/下移按镜头 id 定位:筛选或排序后可见序号 ≠ 全量序号,用行号会移动错镜头 */
|
||
async function move(shot: any, delta: number) {
|
||
const rows = live.current.shots
|
||
const at = rows.findIndex((s) => s.id === shot.id)
|
||
const target = at + delta
|
||
if (at < 0 || target < 0 || target >= rows.length) return
|
||
await run('调整顺序', () => api.post(`/api/projects/${projectId}/shots/bulk`,
|
||
{ action: 'move', shot_ids: [shot.id], index: target + 1 }))
|
||
}
|
||
function canMove(shot: any, delta: number) {
|
||
const at = shots.findIndex((s) => s.id === shot.id)
|
||
return at >= 0 && at + delta >= 0 && at + delta < shots.length
|
||
}
|
||
/** 卡片上的「⧉」只复制当前镜头,不跟着勾选集走 */
|
||
async function duplicateOne(shot: any) {
|
||
await run('复制镜头', () => api.post(`/api/projects/${projectId}/shots/bulk`,
|
||
{ action: 'duplicate', shot_ids: [shot.id] }))
|
||
notify(`已复制镜头 #${shot.order_index}`)
|
||
}
|
||
|
||
/**
|
||
* shift 范围勾选。
|
||
*
|
||
* 参数收的是布尔而不是事件对象:旧站直接把 @change 的原生 Event 传进来读 shiftKey,
|
||
* React 的合成 ChangeEvent 类型上却没有这个字段(它在 MouseEvent 上),
|
||
* 调用点从 nativeEvent 取一次,这里就不再关心事件长什么样。
|
||
*/
|
||
function toggleCheck(id: number, shift = false) {
|
||
const next = new Set(checked)
|
||
if (shift && shots.length) {
|
||
const last = [...next].pop()
|
||
if (last !== undefined) {
|
||
const [a, b] = [shots.findIndex((s) => s.id === last), shots.findIndex((s) => s.id === id)]
|
||
shots.slice(Math.min(a, b), Math.max(a, b) + 1).forEach((s) => next.add(s.id))
|
||
setChecked(next)
|
||
return
|
||
}
|
||
}
|
||
if (next.has(id)) next.delete(id)
|
||
else next.add(id)
|
||
setChecked(next)
|
||
}
|
||
function checkAll() {
|
||
setChecked(checked.size === filtered.length ? new Set() : new Set(filtered.map((s) => s.id)))
|
||
}
|
||
function clearCheck() { setChecked(new Set()) }
|
||
|
||
async function bulkAction(action: 'duplicate' | 'delete' | 'move' | 'patch', extra: any = {}, label = '') {
|
||
const ids = [...checked]
|
||
if (!ids.length) { setError('请先勾选镜头'); return }
|
||
if (action === 'delete') {
|
||
const ok = await confirmAction({
|
||
title: `删除选中的 ${ids.length} 个镜头?`,
|
||
desc: '已生成的产物文件保留,但这些镜头的关联会解除,不可恢复。',
|
||
tone: 'danger', confirmText: '删除', confirmIcon: <IconDelete />
|
||
})
|
||
if (!ok) return
|
||
}
|
||
const ok = await run(label || '批量操作',
|
||
() => api.post(`/api/projects/${projectId}/shots/bulk`, { action, shot_ids: ids, ...extra }))
|
||
if (ok) { clearCheck(); notify(label ? `${label}完成(${ids.length} 个镜头)` : '批量操作完成') }
|
||
}
|
||
|
||
async function applyBulkPatch() {
|
||
const fields: any = {}
|
||
Object.entries(bulk.fields).forEach(([key, value]) => { if (value !== '' && value !== null) fields[key] = value })
|
||
if (!Object.keys(fields).length) { setError('请至少填写一个要统一修改的字段'); return }
|
||
await bulkAction('patch', { fields }, '批量修改')
|
||
setBulk({ open: false, fields: { ...EMPTY_BULK } })
|
||
}
|
||
|
||
/* ---------- 逐句台词 / 环境声 / 镜头音效 ---------- */
|
||
function addLine() {
|
||
setDraft((prev) => {
|
||
const last = prev.lines[prev.lines.length - 1]
|
||
return { ...prev, lines: [...prev.lines,
|
||
{ character_id: last?.character_id ?? null, name: last?.name ?? '', text: '' }] }
|
||
})
|
||
setDirty(true)
|
||
}
|
||
function removeLine(index: number) {
|
||
setDraft((prev) => ({ ...prev, lines: prev.lines.filter((_, i) => i !== index) }))
|
||
setDirty(true)
|
||
}
|
||
function patchLine(index: number, patch: Partial<DialogueLine>) {
|
||
setDraft((prev) => ({ ...prev,
|
||
lines: prev.lines.map((row, i) => (i === index ? { ...row, ...patch } : row)) }))
|
||
setDirty(true)
|
||
}
|
||
function lineSpeakerName(row: DialogueLine) {
|
||
const hit = characters.find((c: any) => c.id === row.character_id)
|
||
return hit?.name || row.name || ''
|
||
}
|
||
|
||
/** 与预检 no_speaker / joint_speaker_unbound 同一口径,只是提前到编辑时说清楚,
|
||
* 不必等保存后回项目概览才发现「这个人下镜头又换了副嗓子」。
|
||
* 本镜显式指定了声线时逐句不再依赖角色默认,提示自动消失。 */
|
||
function lineVoiceIssue(row: DialogueLine): string {
|
||
if (draft.voice_asset_id || binding.voice_asset_id) return ''
|
||
if (!row.character_id) return '未指定说话人:这一句的音色与字幕署名只能由模型即兴'
|
||
const hit = characters.find((c: any) => c.id === row.character_id)
|
||
if (!hit) return ''
|
||
return hit.default_voice_id ? ''
|
||
: `「${hit.name}」还没有默认声线:到人物资产里绑定后,跨镜头才是同一个嗓子`
|
||
}
|
||
|
||
function addSfx() {
|
||
const first = sfxAssets[0]
|
||
setDraft((prev) => ({ ...prev, sound_effects: [...prev.sound_effects, {
|
||
name: first?.name || '', asset_id: first?.id ?? null, path: first?.path || '',
|
||
offset_ms: 0, duration_ms: first?.duration_ms ? Math.round(first.duration_ms) : 3000, gain_db: -8
|
||
}] }))
|
||
setDirty(true)
|
||
}
|
||
function removeSfx(index: number) {
|
||
setDraft((prev) => ({ ...prev, sound_effects: prev.sound_effects.filter((_, i) => i !== index) }))
|
||
setDirty(true)
|
||
}
|
||
function patchSfx(index: number, patch: Record<string, any>) {
|
||
setDraft((prev) => ({ ...prev,
|
||
sound_effects: prev.sound_effects.map((row: any, i: number) => (i === index ? { ...row, ...patch } : row)) }))
|
||
setDirty(true)
|
||
}
|
||
/** 换音效素材时顺手把名字/路径/长度对齐:path 是入库快照,留旧值会把上一段声音混进这一镜 */
|
||
function pickSfx(index: number, assetId: number | null) {
|
||
const hit = sfxAssets.find((a: any) => a.id === assetId)
|
||
patchSfx(index, {
|
||
asset_id: assetId,
|
||
name: hit?.name ?? '',
|
||
path: hit?.path ?? '',
|
||
...(hit?.duration_ms ? { duration_ms: Math.round(hit.duration_ms) } : {})
|
||
})
|
||
}
|
||
|
||
async function loadSfx() {
|
||
try {
|
||
const data = await api.get(`/api/projects/${projectId}/assets?kind=sfx&owner_type=project`)
|
||
setSfxAssets((data?.assets || data?.items || []).filter((a: any) => a.kind === 'sfx' || !a.kind))
|
||
} catch { setSfxAssets([]) }
|
||
}
|
||
|
||
/* ---------- 素材上传 ---------- */
|
||
async function onAsset(file: File | null, kind: string, name: string) {
|
||
const selected = live.current.selectedId
|
||
if (!file || !selected) { setError('请先选择镜头'); return }
|
||
const ok = await run('上传素材',
|
||
() => api.upload(`/api/projects/${projectId}/shots/${selected}/assets`, api.formData({ kind, name }, file)))
|
||
if (ok) {
|
||
notify(`已上传 ${file.name}`)
|
||
const as = await api.get(`/api/projects/${projectId}/shots/${selected}`)
|
||
setDetail(as.shot)
|
||
}
|
||
}
|
||
|
||
/* ---------- 导入 ---------- */
|
||
async function previewText() {
|
||
if (!script.script_text.trim()) { setError('请先粘贴脚本文本'); return }
|
||
setPreview(null)
|
||
await run('解析脚本', async () => {
|
||
setPreview(await api.post(`/api/projects/${projectId}/shots/preview`, {
|
||
script_text: script.script_text, default_duration: script.default_duration,
|
||
image_names: imageFiles.map((f) => f.name)
|
||
}))
|
||
})
|
||
}
|
||
|
||
async function doImport(dry: boolean) {
|
||
if (importMode === 'paste' && !script.script_text.trim()) { setError('请先粘贴脚本文本'); return }
|
||
if (importMode === 'file' && !scriptFile) { setError('请选择脚本文件'); return }
|
||
setPreview(null)
|
||
const ok = await run(dry ? '预演导入' : '导入分镜', async () => {
|
||
const form = api.formData({
|
||
script_text: importMode === 'paste' ? script.script_text : '',
|
||
script_name: importMode === 'file' ? (scriptFile?.name || '') : '',
|
||
default_duration: script.default_duration, dry_run: dry,
|
||
replace: script.replace, keep_existing: script.keep_existing
|
||
}, importMode === 'file' ? scriptFile : null, 'script')
|
||
imageFiles.forEach((f) => form.append('images', f))
|
||
const res = await api.upload(`/api/projects/${projectId}/import`, form)
|
||
if (dry) setPreview(res)
|
||
else notify(`导入完成:新建 ${res.created} 个镜头,自动绑定人物 ${res.bound_characters}、场景 ${res.bound_scenes},图片 ${res.images} 张`)
|
||
return res
|
||
})
|
||
if (ok && !dry) { setShowImport(false); setPreview(null); setImageFiles([]) }
|
||
}
|
||
|
||
/* ---------- 预览 ---------- */
|
||
function previewShot(shot: any, which: string) {
|
||
const source = detail?.id === shot.id ? [detail, ...filtered] : filtered
|
||
const queue = shotMediaQueue(source, { shot, which })
|
||
const at = queue.findIndex((x) => x.group === `shot#${shot.id}`)
|
||
if (at < 0) return
|
||
openPreview(queue, at)
|
||
}
|
||
|
||
/** 「✎ 改文案」:打开检查器并把光标送到画面描述,避免在长表单里翻找 */
|
||
async function focusText(shot: any) {
|
||
setInspectorTab('shot')
|
||
if (live.current.selectedId !== shot.id) await select(shot.id, false)
|
||
/* 四个页签的内容全都保持挂载、只用 hidden 收起来(见检查器注释),
|
||
所以 ref 一直挂在节点上;再等两帧让 hidden 真正摘掉,量出来的位置才对。 */
|
||
await new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())))
|
||
const el = descRef.current
|
||
if (!el) return
|
||
el.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||
el.focus({ preventScroll: true })
|
||
el.setSelectionRange(el.value.length, el.value.length)
|
||
}
|
||
|
||
/* ---------- 生命周期 ---------- */
|
||
useEffect(() => {
|
||
loadProviders()
|
||
load(false)
|
||
loadSfx()
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
}, [])
|
||
|
||
/* 换项目:收起勾选并重灌数据。首帧由上面的挂载 effect 负责,
|
||
这里用 ref 记住上一次的项目号,否则进页面时两个 effect 会各拉一遍全量看板。 */
|
||
const lastProject = useRef(projectId)
|
||
useEffect(() => {
|
||
if (lastProject.current === projectId) return
|
||
lastProject.current = projectId
|
||
clearCheck()
|
||
load(false)
|
||
loadSfx()
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
}, [projectId])
|
||
|
||
/* 看板里有镜头在跑时 10 秒刷一次;正在写表单/上传/导入时不刷,
|
||
否则敲字敲到一半整屏重排,草稿还可能被后端返回值盖掉。 */
|
||
useAutoRefresh(() => void load(), 10000, !!busy, !!busy || dirty || creating || showImport)
|
||
|
||
/* ---------- 键盘:J/K 或方向键切换镜头,Esc 关闭检查器 ----------
|
||
监听只挂一次,动作走 ref:把 handler 随渲染重建的话,
|
||
每次按键都换一次 addEventListener/removeEventListener,长按方向键会漏键。 */
|
||
const fns = useRef({ saveShot, goShot, toggleCheck, closeInspector })
|
||
fns.current = { saveShot, goShot, toggleCheck, closeInspector }
|
||
useEffect(() => {
|
||
const onKey = (ev: KeyboardEvent) => {
|
||
const el = ev.target as HTMLElement
|
||
const typing = ['INPUT', 'TEXTAREA', 'SELECT'].includes(el?.tagName || '')
|
||
if (ev.key === 'Escape') {
|
||
// 预览器自己处理 Esc,别连带把检查器也关掉
|
||
if (live.current.previewIsOpen) return
|
||
// 抽屉/检查器里的下拉、菜单开着时,这一下是收浮层,不是关检查器
|
||
if (floatingLayerOpen()) return
|
||
if (!typing) {
|
||
setShowImport(false)
|
||
void fns.current.closeInspector()
|
||
}
|
||
return
|
||
}
|
||
if (typing) return
|
||
if ((ev.metaKey || ev.ctrlKey) && ev.key.toLowerCase() === 's') {
|
||
ev.preventDefault()
|
||
if (live.current.selectedId || live.current.creating) void fns.current.saveShot()
|
||
return
|
||
}
|
||
if (ev.key === 'j' || ev.key === 'ArrowDown') { ev.preventDefault(); void fns.current.goShot(1) }
|
||
if (ev.key === 'k' || ev.key === 'ArrowUp') { ev.preventDefault(); void fns.current.goShot(-1) }
|
||
if (ev.key === 'x' && live.current.selectedId) {
|
||
ev.preventDefault()
|
||
fns.current.toggleCheck(live.current.selectedId)
|
||
}
|
||
}
|
||
window.addEventListener('keydown', onKey)
|
||
return () => window.removeEventListener('keydown', onKey)
|
||
}, [])
|
||
|
||
return (
|
||
<PageStack>
|
||
{/* ===== 工具条:吸在应用顶栏下沿,「新增镜头 / 切视图 / 收概况」始终够得到 =====
|
||
以前这是一条自绘 div(rounded-lg border bg-bg-container py-4 px-5)+ 四个
|
||
Stat variant="inline":卡片头是 antd 的,这一条却不是,圆角、内边距、
|
||
分隔线全都自己定,于是它是全站唯一「像卡皮、但不是卡」的横条。
|
||
现在它就是 <Toolbar>(只有卡头的 Card),指标改成一行摘要文字。 */}
|
||
{/* 页头(第 1 条):「导入」和「新建」是同一件事的两种入口(都是往工作台里加镜头),
|
||
永远并排,整页成立 → 进 PageHead,不再混在吸顶工具条的视图切换旁边。 */}
|
||
<PageHead
|
||
title="分镜与脚本"
|
||
sub="逐镜维护脚本、关键帧与提示词。看板适合逐镜对照画面,分镜表适合一屏看更多、批量改参数。"
|
||
actions={<>
|
||
<Button type="primary" onClick={() => { setShowImport(!showImport); setCreating(false) }}
|
||
icon={<IconUpload />}>
|
||
导入脚本 / 关键帧
|
||
</Button>
|
||
<Button type="dashed" onClick={startCreate} icon={<IconAdd />}>新增镜头</Button>
|
||
</>}
|
||
/>
|
||
|
||
{/* 吸顶工具条只剩「这一页现在是什么规模 + 用哪种版式看」。
|
||
项目概况不在这里也不在外壳:入口只有顶栏那颗流程控制台,点开是右侧抽屉,
|
||
所以这一页不再重复一颗「展开概况」(2026-11 第十一轮)。 */}
|
||
<Toolbar
|
||
sticky
|
||
info={<Value>共 {shots.length} 镜 · 计划 {plannedDuration.toFixed(1)}s · 已合格 {approvedCount} 镜{issueCount ? ` · 有阻塞 ${issueCount} 镜` : ''}</Value>}
|
||
actions={<ViewSwitch value={view} onChange={setView} label="切换分镜视图"
|
||
items={[{ value: 'grid', label: <><IconGrid />看板</>,
|
||
hint: '网格看板:缩略图 + 脚本要点,逐镜对照最舒服' },
|
||
{ value: 'table', label: <><IconListOrdered />分镜表</>,
|
||
hint: '分镜表:一屏看更多镜,便于批量勾选与改参数' }]} />} />
|
||
|
||
{/* ===== 筛选 / 导出 ===== */}
|
||
<Panel>
|
||
{/* 4 个筛选字段铺 4 等分:搜索占一格,控件右边缘与同排对齐(R7 栅格条) */}
|
||
<Ctlbar className="!mb-0" cols={4}>
|
||
<Field inline label="搜索" width="grow">
|
||
<SearchInput value={keyword} onChange={(e) => setKeyword(e.target.value)} aria-label="搜索分镜" placeholder="镜号 / 标题 / 画面 / 台词 / 角色 / 场景…" />
|
||
</Field>
|
||
<Field inline label="状态" width="narrow">
|
||
<Select ariaLabel="按镜头状态筛选" value={statusFilter} onChange={setStatusFilter}
|
||
options={[{ value: '', label: '全部状态' },
|
||
...((meta?.shot_statuses as string[]) || SHOT_STATUS_FALLBACK)
|
||
.map((s) => ({ value: s, label: statusLabel(s) }))]} />
|
||
</Field>
|
||
<Field inline label="模式" width="narrow">
|
||
<Select ariaLabel="按生成模式筛选" value={modeFilter} onChange={setModeFilter}
|
||
options={[{ value: '', label: '全部模式' }, ...options('mode')]} />
|
||
</Field>
|
||
<Field inline label="排序" width="narrow">
|
||
<Select ariaLabel="分镜排序" value={sortKey} onChange={(next) => setSortKey(next as typeof sortKey)}
|
||
options={[{ value: 'order', label: '按镜序' }, { value: 'status', label: '按状态' },
|
||
{ value: 'duration', label: '按时长' }]} />
|
||
</Field>
|
||
<Chip active={issueOnly} onClick={() => setIssueOnly(!issueOnly)}>仅看阻塞 {issueCount}</Chip>
|
||
<Chip active={noKeyframeOnly} onClick={() => setNoKeyframeOnly(!noKeyframeOnly)}>仅看缺关键帧</Chip>
|
||
<BarRight>
|
||
<ExportMenu items={[{ label: 'Markdown(分镜脚本)', href: exportHref(projectId, 'md'), hint: '导入回写、给编剧看都用它' },
|
||
{ label: 'CSV(表格)', href: exportHref(projectId, 'csv'), hint: '进 Excel 排产期' },
|
||
{ label: 'JSON(原样字段)', href: exportHref(projectId, 'json'), hint: '交给外部管线' }]} />
|
||
</BarRight>
|
||
</Ctlbar>
|
||
</Panel>
|
||
|
||
<ErrorText>{error}</ErrorText>
|
||
{notice ? <Notice className="mb-0">{notice}</Notice> : null}
|
||
{busy ? <span className={MUTED}><Spinner /> {busy}…</span> : null}
|
||
|
||
{/* ===== 批量操作条 ===== */}
|
||
{checked.size ? (
|
||
/* 勾选之后浮出来的批量条:它是一块卡片(卡头 = 已选数量 + 动作,
|
||
正文 = 「统一改参数」那一排字段),不再是页面里自绘的渐变横条。 */
|
||
<Panel className="!border-primary-border">
|
||
<PanelHead className="!mb-0" title={`已选 ${checked.size} 个镜头`} right={<>
|
||
<Button size="sm" onClick={() => void bulkAction('duplicate', {}, '复制镜头')} icon={<IconCopy />}>复制</Button>
|
||
<Button size="sm" onClick={() => void bulkAction('move', { index: 1 }, '前移到片头')} icon={<IconToTop />}>移到最前</Button>
|
||
<Button size="sm" onClick={() => setBulk((prev) => ({ ...prev, open: !prev.open }))} icon={<IconParams />}>统一改参数</Button>
|
||
<Button type="text" danger onClick={() => void bulkAction('delete', {}, '删除镜头')} icon={<IconDelete />}>删除</Button>
|
||
<Button icon={<IconClose />} size="sm" onClick={clearCheck}>取消选择</Button>
|
||
</>} />
|
||
{bulk.open ? (
|
||
/* 批量改字段:4 个字段 + 1 颗应用按钮=5 等分一行放完(三元分支里不能放 JSX 注释) */
|
||
<Ctlbar className="mt-4 !mb-0 border-t border-dashed border-border-secondary pt-4" cols={5}>
|
||
<Field inline label="生成模式">
|
||
<Select value={bulk.fields.mode} placeholder="不改"
|
||
onChange={(next) => setBulk((prev) => ({ ...prev, fields: { ...prev.fields, mode: next } }))}
|
||
options={[{ value: '', label: '不改' }, ...options('mode')]} />
|
||
</Field>
|
||
<Field inline label="时长(秒)" width="narrow">
|
||
<MaybeNumberInput min="0.5" step="0.5" placeholder="不改" value={bulk.fields.duration} onChange={(v) => setBulk((prev) => ({ ...prev,
|
||
fields: { ...prev.fields, duration: v } }))} />
|
||
</Field>
|
||
<Field inline label="景别">
|
||
<Select value={bulk.fields.shot_size} placeholder="不改"
|
||
onChange={(next) => setBulk((prev) => ({ ...prev, fields: { ...prev.fields, shot_size: next } }))}
|
||
options={[{ value: '', label: '不改' }, ...options('shot_size')]} />
|
||
</Field>
|
||
<Field inline label="出转场">
|
||
<Select value={bulk.fields.transition_out} placeholder="不改"
|
||
onChange={(next) => setBulk((prev) => ({ ...prev, fields: { ...prev.fields, transition_out: next } }))}
|
||
options={[{ value: '', label: '不改' }, ...options('transition')]} />
|
||
</Field>
|
||
<Button icon={<IconCheck />} type="primary" disabled={!!busy} onClick={applyBulkPatch}>
|
||
应用到 {checked.size} 个镜头
|
||
</Button>
|
||
</Ctlbar>
|
||
) : null}
|
||
</Panel>
|
||
) : null}
|
||
|
||
{/* ===== 导入脚本 / 关键帧(图2 节点②)===== */}
|
||
{showImport ? (
|
||
<Panel>
|
||
<PanelHead
|
||
title="分镜脚本 / 关键帧导入"
|
||
right={<Row tight>
|
||
<Chip active={importMode === 'paste'} onClick={() => setImportMode('paste')}>粘贴脚本</Chip>
|
||
<Chip active={importMode === 'file'} onClick={() => setImportMode('file')}>上传脚本文件</Chip>
|
||
<Button icon={<IconChevronUp />} size="sm" onClick={() => setShowImport(false)}>收起</Button>
|
||
</Row>}
|
||
/>
|
||
<FormRow cols={2}>
|
||
{importMode === 'paste' ? (
|
||
<FieldBlock label="脚本文本">
|
||
<TextArea rows={10} spellCheck={false} value={script.script_text} title={'按「# 镜头 N:标题」分段,支持字段:画面 / 景别 / 视角 / 运镜 / 时长 / 台词 / 说话人 / 出镜角色 / 场景 / 转场 / 提示词 / 关键帧'} onChange={(e) => setScript((prev) => ({ ...prev, script_text: e.target.value }))} placeholder={'# 镜头 1:启航\n画面: 星舰舰桥,林澈凝视全息星图\n景别: 中景\n运镜: 推镜\n时长: 4\n台词: 我们出发吧\n说话人: 林澈\n出镜角色: 林澈\n场景: 星舰舰桥\n关键帧: s01.png'} />
|
||
</FieldBlock>
|
||
) : (
|
||
<FieldBlock label="脚本文件" title="支持 .txt / .md / .csv / .tsv / .json / .srt / .ass / .vtt / .docx">
|
||
<FilePick icon={<IconUpload />} label={scriptFile ? `已选:${scriptFile.name}` : '选择脚本文件'}
|
||
accept=".txt,.md,.csv,.tsv,.json,.srt,.ass,.vtt,.docx"
|
||
onFiles={(files) => setScriptFile(files[0] || null)} />
|
||
</FieldBlock>
|
||
)}
|
||
<div className="min-w-0">
|
||
<FieldBlock
|
||
label="关键帧图片"
|
||
title="可多选,也可传 zip。文件名与「关键帧:」或镜号(01.png / S03.jpg)匹配即自动绑定;对不上镜号的会单独列出来,需要你手工指定">
|
||
<FilePick icon={<IconUpload />} label={imageFiles.length ? `已选 ${imageFiles.length} 个文件` : '选择图片 / zip'}
|
||
accept="image/*,.zip" multiple onFiles={(files) => setImageFiles(files)} />
|
||
</FieldBlock>
|
||
{imageFiles.length ? (
|
||
<TagGroup className="mb-0 mt-2">
|
||
{imageFiles.slice(0, 12).map((f) => <Tag key={f.name}>{f.name}</Tag>)}
|
||
{imageFiles.length > 12 ? <Tag>+{imageFiles.length - 12}</Tag> : null}
|
||
</TagGroup>
|
||
) : null}
|
||
<Ctlbar>
|
||
<Field inline label="默认时长(秒)" width="narrow">
|
||
<NumberInput min="0.5" step="0.5" value={script.default_duration} onChange={ (v) => setScript((prev) => ({ ...prev, default_duration: v }))} />
|
||
</Field>
|
||
<ActionGroup>
|
||
<Check checked={script.keep_existing}
|
||
onChange={(next) => setScript((prev) => ({ ...prev, keep_existing: next }))}>保留已有镜头</Check>
|
||
<Check checked={script.replace}
|
||
onChange={(next) => setScript((prev) => ({ ...prev, replace: next }))}>替换同名镜头</Check>
|
||
</ActionGroup>
|
||
</Ctlbar>
|
||
<Actions>
|
||
{/* 预览 → 预演 → 正式导入是同一条流程,读的顺序就是点的顺序:整组不换行 */}
|
||
<ActionGroup>
|
||
<Button disabled={!!busy} onClick={previewText} icon={<IconSearch />}>文本预览</Button>
|
||
<Button disabled={!!busy} onClick={() => void doImport(true)} icon={<IconPlayCircle />}>导入预演(含图片匹配)</Button>
|
||
<Button type="primary" disabled={!!busy} onClick={() => void doImport(false)} icon={<IconDownload />}>正式导入</Button>
|
||
</ActionGroup>
|
||
</Actions>
|
||
</div>
|
||
</FormRow>
|
||
|
||
{preview ? (
|
||
<>
|
||
<Divider />
|
||
<SectionTitle className="!mb-3 !mt-0 !text-sm !text-text"
|
||
action={preview.unmatched_images?.length
|
||
? <Tag tone="warn">未匹配图片:{preview.unmatched_images.join(', ')}</Tag>
|
||
: <Tag tone="ok">图片全部匹配</Tag>}>
|
||
解析结果:{preview.parsed} 个镜头
|
||
{preview.created !== undefined ? ` · 实际新建 ${preview.created}` : ''}
|
||
</SectionTitle>
|
||
<Table minWidth={1040} maxHeight={300} rowKey={(_: any, i: any) => String(i)}
|
||
dataSource={preview.shots || []} columns={PREVIEW_COLS} />
|
||
</>
|
||
) : null}
|
||
</Panel>
|
||
) : null}
|
||
|
||
{/* ===== 看板 / 分镜表 =====
|
||
旧版这里是一个会随检查器开合切换列数的 grid(.sb-body / .with-inspector)。
|
||
检查器改成 fixed 常驻之后主区永远是单列,再套一层 grid 只会让子元素
|
||
忘掉 min-w-0(规范 §7:grid 子项一律 min-w-0),所以这里只剩一个容器。
|
||
症状:容器以前写成 <main>,而 App 外壳已经有一个 <main>——页面里套出
|
||
两个 main 地标(读屏软件会念两遍「主内容」,体检里 locator("main")
|
||
也因 strict mode 命中两个节点而报错)。
|
||
做法:一页只准有一个 main,它在 app/App.tsx;页面内层是 div。 */}
|
||
<div className="min-w-0">
|
||
{loading ? (
|
||
/* 镜头列表还没到过 = 这一屏的首帧(阶段 4)。卡片墙的形状由骨架先占住,
|
||
读者一眼看出「下面要长出一排卡」,而不是「这个项目一个镜头都没有」。
|
||
面板头那颗内联 Spinner 不动:那是局部刷新,不是首屏。 */
|
||
<SkeletonBlock rows={6} label="正在载入分镜" />
|
||
) : !shots.length ? (
|
||
<Empty>还没有镜头。点上方「导入脚本 / 关键帧」批量建镜,或「新增镜头」手工写第一镜。</Empty>
|
||
) : !filtered.length ? (
|
||
<Empty>
|
||
<div className="flex min-w-0 flex-wrap items-center justify-center gap-2">
|
||
当前筛选条件下没有镜头。
|
||
<Button icon={<IconClose />} size="sm"
|
||
onClick={() => {
|
||
setKeyword(''); setStatusFilter(''); setModeFilter('')
|
||
setIssueOnly(false); setNoKeyframeOnly(false)
|
||
}}>
|
||
清除筛选
|
||
</Button>
|
||
</div>
|
||
</Empty>
|
||
) : view === 'grid' ? (
|
||
/* 258px 是「缩略图 + 两行说明 + 脚注三个按钮」不塌的地板;
|
||
1240px 没有对应的命名断点(mid=1180 / mid2=1100),只能写任意值变体,
|
||
否则 1200px 的笔记本上还按 258px 排,一屏只剩三列。 */
|
||
<div className="grid min-w-0 grid-cols-[repeat(auto-fill,minmax(258px,1fr))] gap-3 max-[1240px]:grid-cols-[repeat(auto-fill,minmax(224px,1fr))]">
|
||
{filtered.map((s) => (
|
||
<ShotCard
|
||
key={s.id}
|
||
shot={s}
|
||
projectId={projectId}
|
||
selected={s.id === selectedId}
|
||
draggedOver={dragOver === s.id}
|
||
picked={checked.has(s.id)}
|
||
busy={!!busy}
|
||
onSelect={() => void select(s.id)}
|
||
onCheck={(shift) => toggleCheck(s.id, shift)}
|
||
onDragStart={() => startDrag(s.id)}
|
||
onDragOverItem={() => overDrag(s.id)}
|
||
onDragEnd={() => { setDragOver(null); setDragging(null) }}
|
||
onDropItem={() => void dropOn(s.id)}
|
||
onPreview={(which) => previewShot(s, which)}
|
||
onText={() => void focusText(s)}
|
||
onDuplicate={() => void duplicateOne(s)}
|
||
onRemove={() => void removeShot(s)}
|
||
/>
|
||
))}
|
||
</div>
|
||
) : (
|
||
<Panel>
|
||
{/* 分镜表:antd Table。
|
||
勾选交还给 antd 的 rowSelection——列头复选框 + 「全选」都是它自带的,
|
||
页面不再手搓那一行「全选(N)」;选中底色直接复用 antd 自己的
|
||
.ant-table-row-selected,它跟着 Table.rowSelectedBg token 走。
|
||
可拖的是整行:onRow 把 draggable/onDrop 落到底层 <tr> 上,
|
||
列首那格只负责给出把手(HolderOutlined = antd 拖拽排序的标准图形)。
|
||
行不写内联高度,密度由 kit 的 size=small 统一下发。 */}
|
||
<Table minWidth={1180} maxHeight={false} rowKey="id" dataSource={filtered}
|
||
rowSelection={{
|
||
selectedRowKeys: [...checked],
|
||
preserveSelectedRowKeys: true,
|
||
columnWidth: 42,
|
||
onSelect: (s: any, _on: boolean, _rows: any, ev: any) => toggleCheck(s.id, !!(ev && ev.shiftKey)),
|
||
onSelectAll: () => checkAll()
|
||
}}
|
||
rowClassName={(s: any) => cn('cursor-pointer',
|
||
/* 三态顺序 = 基础 → 勾选 → 选中 → 拖拽落点,跟看板卡一致;
|
||
tailwind-merge 留最后一条,「选中 + 勾选」才是看板里那种
|
||
「既是当前镜头又被选中」的叠色,而不是互相抹掉。 */
|
||
s.id === selectedId && '[&>td]:bg-primary-bg',
|
||
checked.has(s.id) && '[&>td]:inset-shadow-[2px_0_0_var(--ant-color-primary-border)]',
|
||
s.id === selectedId && checked.has(s.id) && '[&>td]:bg-primary-bg',
|
||
dragOver === s.id && '[&>td]:border-t [&>td]:border-dashed [&>td]:border-info [&>td]:bg-fill-tertiary')}
|
||
onRow={(s: any) => ({
|
||
draggable: true,
|
||
title: '按住整行拖拽即可改镜序',
|
||
onDragStart: () => startDrag(s.id),
|
||
onDragOver: (ev: any) => { ev.preventDefault(); overDrag(s.id) },
|
||
onDragEnd: () => { setDragOver(null); setDragging(null) },
|
||
onDrop: (ev: any) => { ev.preventDefault(); void dropOn(s.id) },
|
||
onClick: () => void select(s.id)
|
||
})}
|
||
columns={[
|
||
{ title: <span title="按住整行拖拽即可改镜序"><IconDragHandle /></span>,
|
||
width: 62, align: 'center', className: MUTED_MONO,
|
||
render: (_: any, s: any) => <Mono>{s.order_index}</Mono> },
|
||
{ title: '预览', width: 108, render: (_: any, s: any) => (
|
||
<div className={TABLE_THUMB}>
|
||
{s.keyframe_url || s.output_url ? (
|
||
<MediaThumb item={fromShot(s, s.keyframe_url ? 'keyframe' : 'output')}
|
||
width="92px" size="xs" radius="chip" className="cursor-zoom-in"
|
||
onOpen={() => previewShot(s, s.keyframe_url ? 'keyframe' : 'output')} />
|
||
) : <span className="text-text-quaternary"><IconImage /></span>}
|
||
</div>) },
|
||
{ title: '镜头', className: cellWrap, render: (_: any, s: any) => (
|
||
<>
|
||
<b>{s.title || '未命名'}</b>
|
||
<div className={MUTED_MONO}>{s.code}</div>
|
||
</>) },
|
||
{ title: '画面 / 台词', className: cellWrap, render: (_: any, s: any) => (
|
||
<>
|
||
{s.description || '未填写画面描述'}
|
||
{s.dialogue ? <div className={MUTED}>「{s.dialogue}」 {s.speaker_name}</div> : null}
|
||
</>) },
|
||
{ title: '绑定', className: cn(cellWrap, MUTED), render: (_: any, s: any) => (
|
||
<>
|
||
{(s.characters || []).map((c: any) => c.name).join('、') || '—'}
|
||
<div>{(s.scenes || []).map((c: any) => c.name).join('、') || '—'}</div>
|
||
</>) },
|
||
{ title: '时长', width: 72, align: 'right', className: MUTED_MONO,
|
||
render: (_: any, s: any) => `${s.duration}s` },
|
||
{ title: '摄影', width: 150, className: MUTED,
|
||
render: (_: any, s: any) => `${opt('shot_size', s.shot_size)} · ${opt('camera_movement', s.camera_movement)}` },
|
||
{ title: '状态', width: 132, render: (_: any, s: any) => (
|
||
<>
|
||
<Status value={s.status} />
|
||
{!s.ready
|
||
? <ErrorText>{issueOf(s, 'error')[0]?.message || '预检未通过'}</ErrorText>
|
||
: (s.qc_score !== null && s.qc_score !== undefined
|
||
? <div className={MUTED_MONO}>QC {s.qc_score.toFixed(0)}</div>
|
||
: null)}
|
||
</>) },
|
||
{ title: '操作', width: 208, align: 'right',
|
||
onCell: () => ({ onClick: (ev: any) => ev.stopPropagation() }),
|
||
render: (_: any, s: any) => (
|
||
<Row className="justify-end">
|
||
<Button size="sm" disabled={!canMove(s, -1) || !!busy}
|
||
onClick={() => void move(s, -1)} title="前移" aria-label="前移" icon={<IconArrowUp />} />
|
||
<Button size="sm" disabled={!canMove(s, 1) || !!busy}
|
||
onClick={() => void move(s, 1)} title="后移" aria-label="后移" icon={<IconArrowDown />} />
|
||
<Button size="sm" onClick={() => void focusText(s)}
|
||
title="直接改这一镜的画面描述与台词" icon={<IconEdit />}>文案</Button>
|
||
<Button icon={<IconDelete />} type="text" danger onClick={() => void removeShot(s)} title="删除这一镜" aria-label="删除这一镜" />
|
||
</Row>) }
|
||
]} />
|
||
</Panel>
|
||
)}
|
||
</div>
|
||
|
||
{/* ===== 检查器(inspRef)=====
|
||
它不是 Drawer:Drawer 是模态(Esc 关闭 + 锁滚动 + 遮罩吞点击),
|
||
而改分镜要「左边挑镜头、右边改文案」来回看,遮罩会把看板挡死。
|
||
这里保留抽屉的皮肤(同一套 head/body/actions 类名),自己管开合。 */}
|
||
{selectedId || creating ? (
|
||
<Scrim label="关闭分镜详情" onClose={() => void closeInspector()} />
|
||
) : null}
|
||
{selectedId || creating ? (
|
||
/* 1400 / 1080 / 720 这三档没有命名断点(huge=1440 / mid=1180 / mid2=1100 / nav=900),
|
||
只能写任意值变体:检查器要同时放下「提示词 + 参考图 + 参数」两列,
|
||
按 1180 回落会在 1200px 屏上就把字段挤成一列,编辑区被表单撑爆。 */
|
||
/* z-[60] → LAYER.sheet:检查器压在自己的 Scrim(LAYER.scrim=55)之上(UI规范.md §10) */
|
||
<aside ref={inspRef} style={{ zIndex: LAYER.sheet }} className={cn(
|
||
'fixed top-(--nex-bar) right-0 bottom-0 left-auto flex max-h-[calc(100vh-var(--nex-bar))] '
|
||
+ 'w-[min(max(900px,68vw),1500px)] flex-col overflow-hidden border-l border-border bg-bg-layout shadow-drawer '
|
||
+ 'max-[1400px]:w-[min(880px,calc(100vw-24px))] max-[1080px]:w-[min(760px,calc(100vw-24px))] max-[720px]:w-screen'
|
||
)}>
|
||
<header className={DRAWER_HEAD}>
|
||
<div className="min-w-0">
|
||
{/* 只有已存在的镜头才有「第几镜」可报;新建时不留一行空眉标 */}
|
||
{!creating && (
|
||
<small className="text-xs tracking-wider text-text-tertiary font-bold">
|
||
{current?.code || '镜头'} · 第 {shotPos} / {filtered.length} 镜
|
||
</small>
|
||
)}
|
||
<h2 className={cn(DRAWER_TITLE, !creating && 'mt-1')}>
|
||
{creating ? '新增镜头' : (detail?.title || current?.title || '未命名镜头')}
|
||
</h2>
|
||
</div>
|
||
{/* 逐镜导航与关闭同一组:改一场戏要连着过十几镜,不该反复关抽屉再点卡片 */}
|
||
<div className="flex flex-none items-center gap-2">
|
||
<Button size="sm" disabled={!canStep(-1)}
|
||
title="上一镜(K / ↑)" onClick={() => void goShot(-1)} icon={<IconArrowUp />}>上一镜</Button>
|
||
<Button size="sm" disabled={!canStep(1)}
|
||
title="下一镜(J / ↓)" onClick={() => void goShot(1)} icon={<IconArrowDown />}>下一镜</Button>
|
||
<CloseButton label="关闭分镜详情" onClose={() => { void closeInspector() }} />
|
||
</div>
|
||
</header>
|
||
|
||
<div className="flex-none px-5 pt-3">
|
||
{/* 检查器的四个内部页面用 Tabs;下面四块 Panel 靠 hidden 保持挂载,
|
||
切页签不会把填了一半的表单清掉。 */}
|
||
<Tabs className="w-full" activeKey={inspectorTab}
|
||
onChange={(k) => setInspectorTab(k as InspectorTab)}
|
||
items={[
|
||
{ key: 'shot', label: '镜头' },
|
||
{ key: 'assets', label: '资产', count: binding.character_ids.length + binding.scene_ids.length + (detail?.assets || []).length },
|
||
{ key: 'prompt', label: '提示词', count: revisions.length },
|
||
{ key: 'output', label: '产物' }
|
||
]} />
|
||
</div>
|
||
|
||
<div className={DRAWER_BODY}>
|
||
{/* 列边界由这一层 FormGrid 统一定义:四个页签里的 2/3/4 列字段
|
||
以前各写各的轨道,标题散在 765/845/1003/1162/1241 五个位置。 */}
|
||
<FormGrid>
|
||
{/* 四个页签全部保持挂载、只用 hidden 收起:
|
||
「✎ 改文案」要拿到画面描述的 textarea(descRef),
|
||
卸载式页签切过去才渲染,那个动作就会静默失败。 */}
|
||
<Panel className={cn('bg-bg-container', inspectorTab !== 'shot' && 'hidden')}>
|
||
<SectionTitle title="只改这一镜:保存后提示词与预检即时重算,不必重跑整份分镜"><IconText icon={<IconCompose />}>本镜文案</IconText></SectionTitle>
|
||
<FormRow cols={2}>
|
||
<Field label="标题">
|
||
<Input value={draft.title} onChange={(e) => edit({ title: e.target.value })} />
|
||
</Field>
|
||
<Field label="镜号">
|
||
<Input value={draft.code} placeholder="留空自动编号" onChange={(e) => edit({ code: e.target.value })} />
|
||
</Field>
|
||
</FormRow>
|
||
<FieldBlock label="画面描述" title="这段描述是生成提示词的主体">
|
||
<TextArea ref={descRef} data-field="description" rows={4} value={draft.description} placeholder="星舰舰桥,林澈凝视全息星图" onChange={(e) => edit({ description: e.target.value })} />
|
||
</FieldBlock>
|
||
<FieldBlock label="剧情梗概(可选)">
|
||
<TextArea rows={2} value={draft.synopsis} onChange={(e) => edit({ synopsis: e.target.value })} />
|
||
</FieldBlock>
|
||
<FieldBlock label="本镜风格补充">
|
||
<Input value={draft.style_note} placeholder="只写这一镜与全片基调不同的地方" onChange={(e) => edit({ style_note: e.target.value })} />
|
||
</FieldBlock>
|
||
|
||
<SectionTitle title="一句一行并标清说话人,系统按各自声线逐句配音;留空即这一镜没有人说话"
|
||
action={(
|
||
<>
|
||
{draft.lines.length > 1
|
||
? <Tag tone="info" title="按说话人各自的声线逐句配音">本镜 {draft.lines.length} 人说话</Tag>
|
||
: null}
|
||
<Button type="dashed" htmlType="button" title="再加一句台词" onClick={addLine} icon={<IconAdd />}>加一句</Button>
|
||
</>
|
||
)}>
|
||
<IconText icon={<IconMic />}>台词与配音</IconText>
|
||
</SectionTitle>
|
||
<div className="flex min-w-0 flex-col gap-2">
|
||
{draft.lines.map((row, i) => (
|
||
<DialogueRow key={`line${i}`} index={i} row={row} total={draft.lines.length}
|
||
characters={characters} issue={lineVoiceIssue(row)}
|
||
onSpeaker={(next) => patchLine(i, { character_id: next })}
|
||
onText={(next) => patchLine(i, { text: next })}
|
||
onRemove={() => removeLine(i)} />
|
||
))}
|
||
{!draft.lines.length ? <div className={LINE_EMPTY}>这一镜没有台词</div> : null}
|
||
</div>
|
||
|
||
<FieldBlock label="字幕文本" title="留空则自动取这一镜的台词">
|
||
<TextArea data-field="subtitle" rows={2} value={draft.subtitle_text} onChange={(e) => edit({ subtitle_text: e.target.value })} />
|
||
</FieldBlock>
|
||
<FormRow cols={2}>
|
||
<Field label="环境声"
|
||
title="听得见的东西,用名词短语(键盘敲击声、空调底噪),不要写成句子。模型直出声音时它除了给这一镜铺底噪,还能占住台词前后的空闲时间:MiniMax H3 的音轨和画面一样长,空着的地方它不会留静音,而是从提示词里挑一段画面描述念出来(成片开头那句听不懂的话就是这么来的)。没人说话的镜头同样该填。">
|
||
<Input value={draft.ambience} placeholder="键盘敲击声,办公室底噪" onChange={(e) => edit({ ambience: e.target.value })} />
|
||
</Field>
|
||
<Check checked={draft.subtitle_enabled}
|
||
onChange={(next) => edit({ subtitle_enabled: next })}>启用字幕</Check>
|
||
</FormRow>
|
||
<div className="min-w-0">
|
||
<SectionTitle className="mt-0"
|
||
action={(
|
||
<Button type="dashed" htmlType="button" disabled={!sfxAssets.length}
|
||
onClick={addSfx} icon={<IconAdd />}
|
||
title={sfxAssets.length ? '后期叠加一个音效素材' : '项目里还没有音效素材:到「资产库 → 音效」上传'}>
|
||
添加音效
|
||
</Button>
|
||
)}>
|
||
镜头音效
|
||
</SectionTitle>
|
||
<div className="flex min-w-0 flex-col gap-2">
|
||
{draft.sound_effects.map((row, i) => (
|
||
<SfxRowView key={`sfx${i}`} row={row} assets={sfxAssets}
|
||
onPick={(assetId) => pickSfx(i, assetId)}
|
||
onPatch={(patch) => patchSfx(i, patch)}
|
||
onRemove={() => removeSfx(i)} />
|
||
))}
|
||
</div>
|
||
</div>
|
||
|
||
<SectionTitle title="时长等区间跟随这一镜实际使用的模型;改完点下方「保存镜头」"><IconText icon={<IconVideo />}>摄影与生成参数</IconText></SectionTitle>
|
||
<SectionTitle className="mt-0">摄影</SectionTitle>
|
||
<FormRow cols={4}>
|
||
<Field label="景别">
|
||
<Select value={draft.shot_size} onChange={(next) => edit({ shot_size: next })}
|
||
options={options('shot_size')} />
|
||
</Field>
|
||
<Field label="视角">
|
||
<Select value={draft.camera_angle} onChange={(next) => edit({ camera_angle: next })}
|
||
options={options('camera_angle')} />
|
||
</Field>
|
||
<Field label="运镜">
|
||
<Select value={draft.camera_movement} onChange={(next) => edit({ camera_movement: next })}
|
||
options={options('camera_movement')} />
|
||
</Field>
|
||
<Field label="镜头备注">
|
||
<Input value={draft.lens_note} placeholder="35mm / 浅景深…" onChange={(e) => edit({ lens_note: e.target.value })} />
|
||
</Field>
|
||
</FormRow>
|
||
<SectionTitle className="mt-0">时长与转场</SectionTitle>
|
||
<FormRow cols={3}>
|
||
<Field label="时长(秒)" title={`模型支持区间 ${durationRange || '未声明'}`}>
|
||
<NumberInput step="0.5" min={shotCaps.minDuration || 0.5} max={shotCaps.maxDuration || undefined} value={draft.duration} onChange={ (v) => edit({ duration: v })} />
|
||
</Field>
|
||
<Field label="出转场">
|
||
<Select value={draft.transition_out} onChange={(next) => edit({ transition_out: next })}
|
||
options={options('transition')} />
|
||
</Field>
|
||
<Field label="转场(ms)">
|
||
<NumberInput min="0" step="50" value={draft.transition_duration_ms} onChange={ (v) => edit({ transition_duration_ms: v })} />
|
||
</Field>
|
||
</FormRow>
|
||
<SectionTitle className="mt-0">生成</SectionTitle>
|
||
<FormRow cols={4}>
|
||
<Field label="生成模式">
|
||
<Select value={draft.mode} onChange={(next) => edit({ mode: next })} options={modeOptions} />
|
||
</Field>
|
||
<Field label="种子">
|
||
<NumberInput value={draft.seed} placeholder="留空随机" onChange={ (v) => edit({ seed: v })} />
|
||
</Field>
|
||
{/* 模型覆盖占两格:这一项的标签最长(跟随项目:provider/model),
|
||
单格会截成「跟随项目:…」,看不出到底跟的是哪个模型。 */}
|
||
<Field label="模型覆盖" className="col-span-2">
|
||
<Select value={modelRef} onChange={setModelRef} options={modelChoices} />
|
||
</Field>
|
||
</FormRow>
|
||
<ChipBar className="mb-0">
|
||
<Tag>{shotModelRow ? (shotModelRow.display_name || `${shotModelRow.provider}/${shotModelRow.model}`) : '模型未注册'}</Tag>
|
||
{shotCaps.resolutions.length ? <Tag>分辨率 {shotCaps.resolutions.join(' / ')}</Tag> : null}
|
||
{shotUpscaleTiers.length ? <Tag>放大交付 {shotUpscaleTiers.join(' / ')}</Tag> : null}
|
||
{shotCaps.modes.length ? <Tag>模式 {shotCaps.modes.join(' / ')}</Tag> : null}
|
||
{durationRange ? <Tag>时长 {durationRange}</Tag> : null}
|
||
{shotCaps.fps ? <Tag>{shotCaps.fps}fps</Tag> : null}
|
||
{shotCaps.maxReferenceImages ? <Tag>参考图 ≤ {shotCaps.maxReferenceImages}</Tag> : null}
|
||
</ChipBar>
|
||
{shotWarnings.map((w) => <ErrorText key={w}>{w}</ErrorText>)}
|
||
</Panel>
|
||
|
||
<Panel className={cn('bg-bg-container', inspectorTab !== 'assets' && 'hidden')}>
|
||
<PanelHead title="资产绑定" className="!mb-4" />
|
||
<FormRow>
|
||
<Field label="出镜人物">
|
||
<MultiSelect value={binding.character_ids} ariaLabel="出镜人物" size="md"
|
||
onChange={(next) => patchBinding({ character_ids: next })}
|
||
options={characters.map((c) => ({ value: c.id, label: `${c.name} · ${c.role}` }))} />
|
||
</Field>
|
||
<Field label="场景">
|
||
<MultiSelect value={binding.scene_ids} ariaLabel="场景"
|
||
onChange={(next) => patchBinding({ scene_ids: next })}
|
||
options={scenes.map((s) => ({ value: s.id, label: s.name }))} />
|
||
</Field>
|
||
<Field label="说话人">
|
||
<Select value={binding.speaker_character_id}
|
||
onChange={(next) => patchBinding({ speaker_character_id: next })}
|
||
options={[{ value: null, label: '无台词' },
|
||
...characters.map((c) => ({ value: c.id, label: c.name }))]} />
|
||
</Field>
|
||
<Field label="声线">
|
||
<Select value={binding.voice_asset_id}
|
||
onChange={(next) => patchBinding({ voice_asset_id: next })}
|
||
options={[{ value: null, label: '使用说话人默认声线' },
|
||
...voices.map((v) => ({ value: v.id, label: `${v.name} · ${v.provider}` }))]} />
|
||
</Field>
|
||
</FormRow>
|
||
<Actions>
|
||
<Button icon={<IconCheck />} type="primary" disabled={!!busy || !selectedId} onClick={() => void saveBindings()}
|
||
title="绑定后自动进入参考图与一致性提示词">保存绑定</Button>
|
||
</Actions>
|
||
|
||
<Divider />
|
||
{/* 手涂的 primary 渐变盒(bg-[linear-gradient(...)])属于「第二个调色板」:同一个语义的底块
|
||
全站有好几种长相,圆角/内边距/描边各写各的。底纹改抄 Block 那把尺子 BLOCK_TONE.info
|
||
(antd 的 colorInfoBg + colorInfoBorder),圆角 borderRadiusLG / 内边距 paddingSM
|
||
沿用 Block 里同两组 utility。没有直接套 <Block> 是刻意的:它下发 Dense,
|
||
会把这一整块 md 档表单控件降成 24,和同一抽屉里其它字段差一档(R3)。 */}
|
||
<div className={cn('min-w-0 rounded-lg border p-3 flex flex-col gap-3', BLOCK_TONE.info)}>
|
||
<Between>
|
||
<b className="text-sm text-primary-hover">AI 生成关键帧</b>
|
||
{/* 模型与输出尺寸都是只读回显,收到卡头一行:抽屉里少一个「填不了的输入框」 */}
|
||
<TagGroup size="sm" className="!mb-0">
|
||
<Tag tone={keyframeModel?.available ? 'ok' : 'warn'}>
|
||
{keyframeModel ? `${keyframeModel.provider}/${keyframeModel.model}` : '无可用图像模型'}
|
||
</Tag>
|
||
<Tag>输出 {keyframeGen.width} × {keyframeGen.height}</Tag>
|
||
</TagGroup>
|
||
</Between>
|
||
<FormRow>
|
||
<Field label="图像模型">
|
||
<Select value={keyframeGen.model_id} disabled={!imageProviders.length}
|
||
title={imageProviders.length ? undefined : '没有启用的真实图像模型,先在模型管理中心启用一个'}
|
||
onChange={(next) => setKeyframeGen((prev) => ({ ...prev, model_id: next }))}
|
||
options={imageProviders.map((p) => ({
|
||
value: p.id,
|
||
label: `${p.display_name || p.model}${p.available ? '' : '(未就绪)'}`
|
||
}))} />
|
||
</Field>
|
||
</FormRow>
|
||
<FieldBlock label="关键帧提示词">
|
||
<TextArea rows={5} spellCheck={false} value={keyframeGen.prompt} placeholder="描述这一镜的最终画面、机位、人物动作、光线与场景" onChange={(e) => setKeyframeGen((prev) => ({ ...prev, prompt: e.target.value }))} />
|
||
</FieldBlock>
|
||
<FieldBlock label="负面提示词">
|
||
<TextArea rows={2} spellCheck={false} value={keyframeGen.negative_prompt} onChange={(e) => setKeyframeGen((prev) => ({ ...prev, negative_prompt: e.target.value }))} />
|
||
</FieldBlock>
|
||
<FieldBlock label="参考素材" title="可多选;默认取场景图、人物定妆图与镜头参考图">
|
||
<MultiSelect value={keyframeGen.reference_asset_ids} ariaLabel="关键帧参考素材"
|
||
onChange={(next) => setKeyframeGen((prev) => ({ ...prev, reference_asset_ids: next }))}
|
||
options={imageReferences.map((a) => ({
|
||
value: a.id,
|
||
label: `${a.owner_label} · ${a.kind_label || a.kind} · ${a.name} v${a.version}`
|
||
}))} />
|
||
</FieldBlock>
|
||
<Actions>
|
||
<Button type="primary" disabled={!!busy || !keyframeModel || !selectedId}
|
||
onClick={() => void generateKeyframe()}
|
||
title="使用当前镜头提示词与真实图像模型,生成后自动成为 i2v 首帧" icon={<IconImage />}>生成并设为关键帧</Button>
|
||
<Button icon={<IconReload />} disabled={!detail} onClick={() => syncKeyframeDraft(detail)}>
|
||
恢复镜头提示词与默认参考
|
||
</Button>
|
||
</Actions>
|
||
<ErrorText className="mt-2">
|
||
{imageProviders.length ? '' : '当前没有可用的图像模型,请到模型管理中心启用一个再回来生成关键帧。'}
|
||
</ErrorText>
|
||
</div>
|
||
|
||
<Divider />
|
||
<SectionTitle className="mt-0">镜头素材</SectionTitle>
|
||
<Actions className="mt-0">
|
||
<FilePick icon={<IconUpload />} label="关键帧(首帧)" accept="image/*" title="上传后直接作为 i2v 首帧"
|
||
onFiles={(files) => { void onAsset(files[0], 'keyframe', '关键帧') }} />
|
||
<FilePick icon={<IconUpload />} label="尾帧" accept="image/*" title="首尾帧模式的最后一帧"
|
||
onFiles={(files) => { void onAsset(files[0], 'last_frame', '尾帧') }} />
|
||
<FilePick icon={<IconUpload />} label="参考图" accept="image/*" title="只作一致性参考,不进成片"
|
||
onFiles={(files) => { void onAsset(files[0], 'reference_image', '参考图') }} />
|
||
<FilePick icon={<IconUpload />} label="参考视频" accept="video/*" title="r2v 模式的参考视频"
|
||
onFiles={(files) => { void onAsset(files[0], 'reference_video', '参考视频') }} />
|
||
</Actions>
|
||
{/* 720px 以下退成一列:270px 的地板在检查器最窄档(760 - padding)里会挤出三列,
|
||
缩略图 + 名称 + 版本行全都开始截断。 */}
|
||
<div className="mt-3 grid min-w-0 grid-cols-[repeat(auto-fit,minmax(270px,1fr))] gap-2 max-[720px]:grid-cols-[minmax(0,1fr)]">
|
||
{(detail?.assets || []).map((a: any, ai: number) => (
|
||
<AssetRow key={a.id} asset={a} queue={assetQueue} index={ai}
|
||
onPreview={() => openPreview(assetQueue, ai)} />
|
||
))}
|
||
{!(detail?.assets || []).length
|
||
? (
|
||
<div className={MUTED} title="i2v / 首尾帧模式必须有对应帧图才能通过预检">该镜头暂无素材</div>
|
||
)
|
||
: null}
|
||
</div>
|
||
</Panel>
|
||
|
||
<Panel className={cn('bg-bg-container', inspectorTab !== 'prompt' && 'hidden')}>
|
||
<PanelHead title="提示词与版本" className="!mb-4" />
|
||
<ChipBar>
|
||
<Tag tone={promptForm.auto_sync ? 'ok' : 'warn'}>{promptForm.auto_sync ? '自动组装' : '人工覆盖'}</Tag>
|
||
<Tag>正向 {promptForm.prompt.length} 字</Tag>
|
||
<Tag>负面 {promptForm.negative_prompt.length} 字</Tag>
|
||
</ChipBar>
|
||
<FieldBlock label="正向提示词" title="勾选「跟随镜头参数自动组装」时这里是只读的:手工文本会在下一次保存时被自动组装覆盖">
|
||
<TextArea rows={7} spellCheck={false} value={promptForm.prompt} readOnly={promptForm.auto_sync} onChange={(e) => patchPrompt({ prompt: e.target.value })} />
|
||
</FieldBlock>
|
||
<FieldBlock label="负面提示词">
|
||
<TextArea rows={2} spellCheck={false} value={promptForm.negative_prompt} readOnly={promptForm.auto_sync} onChange={(e) => patchPrompt({ negative_prompt: e.target.value })} />
|
||
</FieldBlock>
|
||
<FormRow>
|
||
<Field label="修改原因">
|
||
<Input value={promptForm.reason} placeholder="例如:加强角色一致性 / 按驳回原因修复" onChange={(e) => patchPrompt({ reason: e.target.value })} />
|
||
</Field>
|
||
</FormRow>
|
||
<Check checked={promptForm.auto_sync} onChange={(next) => patchPrompt({ auto_sync: next })}>
|
||
跟随镜头参数自动组装(勾选后人工文本只读)
|
||
</Check>
|
||
<Actions>
|
||
<Button icon={<IconCheck />} type="primary" disabled={!!busy || !selectedId} onClick={() => void savePrompt()}>保存为新版本</Button>
|
||
</Actions>
|
||
<Divider />
|
||
<SectionTitle className="mt-0">历史版本({revisions.length})</SectionTitle>
|
||
{revisions.slice(0, 12).map((r) => (
|
||
<RevisionCard key={r.id} rev={r} onUse={() => useRevision(r)} />
|
||
))}
|
||
{!revisions.length ? <div className={MUTED}>尚无提示词版本记录。</div> : null}
|
||
</Panel>
|
||
|
||
<Panel className={cn('bg-bg-container', inspectorTab !== 'output' && 'hidden')}>
|
||
<PanelHead title="产物与质检" className="!mb-4" />
|
||
{detail?.output_url ? (
|
||
<>
|
||
<video className="block max-h-[220px] w-full rounded-lg bg-bg-layout" controls
|
||
src={shotVideoSrc} preload="metadata"
|
||
onDoubleClick={() => previewShot(detail, shotOutputWhich(detail, preferVoiceoverAudio))} />
|
||
<ChipBar top>
|
||
<Status value={detail.status} />
|
||
<Tag>实测 {(detail.output_duration || 0).toFixed(2)}s / 目标 {detail.duration}s</Tag>
|
||
<Tag>生成于 {fmtTime(detail.generated_at)}</Tag>
|
||
<Tag>尝试 {detail.attempts} 次</Tag>
|
||
{detail.qc_score !== null && detail.qc_score !== undefined
|
||
? <Tag tone={detail.qc_score >= 80 ? 'ok' : 'warn'}>QC {detail.qc_score.toFixed(0)}</Tag>
|
||
: null}
|
||
<Button icon={<IconEye />} size="sm"
|
||
onClick={() => previewShot(detail, shotOutputWhich(detail, preferVoiceoverAudio))}>大屏预览</Button>
|
||
<ExtLink href={detail.output_url}>原片</ExtLink>
|
||
<Tag tone={detail.preview_ready ? 'ok' : (detail.native_audio && detail.voiceover_url ? 'warn' : 'default')}>
|
||
{detail.preview_ready
|
||
? '正在播放平台配音'
|
||
: (detail.native_audio && detail.voiceover_url ? '当前为模型原声' : '无模型音轨')}
|
||
</Tag>
|
||
{detail.preview_ready
|
||
? (
|
||
<Button icon={<IconSound />} size="sm"
|
||
onClick={() => setPreferVoiceoverAudio(!preferVoiceoverAudio)}>
|
||
{preferVoiceoverAudio ? '听模型原声' : '听平台配音'}
|
||
</Button>
|
||
)
|
||
: (detail.voiceover_url && detail.native_audio
|
||
? (
|
||
<Button icon={<IconDownload />} disabled={busy === '封装审片预览'}
|
||
onClick={() => void buildShotPreview(true)}>封装审片预览</Button>
|
||
)
|
||
: null)}
|
||
</ChipBar>
|
||
{detail.qc?.checks?.length ? (
|
||
<Table minWidth={520} maxHeight={230} rowKey="key"
|
||
dataSource={detail.qc.checks}
|
||
columns={[
|
||
{ title: '检查项', className: cellWrap, render: (_: any, c: any) => c.label },
|
||
{ title: '结论', width: 88, align: 'center', render: (_: any, c: any) => (
|
||
<Tag tone={c.passed ? 'ok' : (c.severity === 'warning' ? 'warn' : 'bad')}>
|
||
{c.passed ? '合格' : (c.severity === 'warning' ? '提醒' : '不合格')}
|
||
</Tag>
|
||
) },
|
||
{ title: '实测', className: cn(cellWrap, MUTED_MONO),
|
||
render: (_: any, c: any) => `${c.value} · ${c.detail}` }
|
||
]} />
|
||
) : null}
|
||
{detail.voiceover_url ? (
|
||
<>
|
||
<Divider />
|
||
<SectionTitle className="mt-0">配音</SectionTitle>
|
||
<AudioPlay src={detail.voiceover_url} label="本镜平台配音"
|
||
durationMs={detail.voiceover_duration_ms} size="sm"
|
||
hint="试听走平台统一音频引擎,切页/换镜头自动停上一段" />
|
||
<Actions>
|
||
<Button icon={<IconEye />} size="sm" onClick={() => previewShot(detail, 'voiceover')}>放大预览</Button>
|
||
</Actions>
|
||
</>
|
||
) : null}
|
||
<Actions>
|
||
<LinkButton icon={<IconAudit />} to={`/projects/${projectId}/review?shot=${selectedId}`} type="primary">前往审核</LinkButton>
|
||
<LinkButton icon={<IconRetry />} to={detail?.output_url ? dispatchLink(projectId, detail) : `/projects/${projectId}/dispatch?shot=${selectedId}`}
|
||
title="只把这一镜排进队列;已有产物时自动带上强制重建">重新生成</LinkButton>
|
||
</Actions>
|
||
</>
|
||
) : (
|
||
<Empty>还没有产物。先在「资产」页签补齐关键帧并通过预检,再到调度中心入队生成。</Empty>
|
||
)}
|
||
{detail?.error_message
|
||
? <ErrorText className="mt-3">{detail.error_code} {detail.error_message}</ErrorText>
|
||
: null}
|
||
</Panel>
|
||
</FormGrid>
|
||
</div>
|
||
|
||
{/* 保存条:抽屉级吸底(不是 body 内 sticky)——长表单滚到哪儿都能存,
|
||
也不会出现「sticky 停在半屏、把后面的控件压在身下」的错位。 */}
|
||
{inspectorTab === 'shot' ? (
|
||
<div className={DRAWER_ACTIONS}>
|
||
<Button icon={<IconAdd />} type="primary" disabled={!!busy} onClick={() => void saveShot()}
|
||
title={creating ? '创建这一镜' : '保存这一镜(⌘S)'}>
|
||
{creating ? '创建镜头' : '保存镜头'}
|
||
</Button>
|
||
<Button icon={<IconClose />} disabled={!dirty} onClick={resetDraft} title="用后端这份重新填一遍表单">放弃修改</Button>
|
||
{dirty
|
||
? <Tag tone="warn">未保存</Tag>
|
||
: (current && !creating
|
||
? <Mono className={MUTED_MONO}>{current.effective_provider}/{current.effective_model}</Mono>
|
||
: null)}
|
||
</div>
|
||
) : null}
|
||
</aside>
|
||
) : null}
|
||
</PageStack>
|
||
)
|
||
}
|
||
|
||
/* ── 页面局部组件 ─────────────────────────────────────────────────────────
|
||
只有分镜页会用的皮肤块放本文件,不进 components/ui:
|
||
它们的类名是从旧站逐条抄来的,脱离这一页就没有第二个使用者,
|
||
提前抽成通用组件只会让 ui 目录变成「什么都往里扔」。 */
|
||
|
||
/**
|
||
* 看板卡(.card):整张卡就是镜头入口,
|
||
* 所以缩略图预览、勾选框、脚注三处都要各自拦下冒泡,否则点一下会变成「选中镜头 + 打开预览」。
|
||
*/
|
||
type ShotCardProps = {
|
||
shot: any
|
||
projectId: number | null
|
||
selected: boolean
|
||
draggedOver: boolean
|
||
picked: boolean
|
||
busy: boolean
|
||
onSelect: () => void
|
||
onCheck: (shift: boolean) => void
|
||
onDragStart: () => void
|
||
onDragOverItem: () => void
|
||
onDragEnd: () => void
|
||
onDropItem: () => void
|
||
onPreview: (which: 'keyframe' | 'output') => void
|
||
onText: () => void
|
||
onDuplicate: () => void
|
||
onRemove: () => void
|
||
}
|
||
|
||
function ShotCard({
|
||
shot: s, projectId, selected, draggedOver, picked, busy,
|
||
onSelect, onCheck, onDragStart, onDragOverItem, onDragEnd, onDropItem,
|
||
onPreview, onText, onDuplicate, onRemove
|
||
}: ShotCardProps) {
|
||
const badge = reviewBadge(s)
|
||
return (
|
||
<article draggable
|
||
/* 选中整镜 = 打开检查器。挂个稳定属性给 scripts/ui/audit.py 点:
|
||
卡片是 <article onClick>,不是 <button>,探针按文案点不中它。 */
|
||
data-shot-card={s.id}
|
||
/* 键盘可达(NEX 08 §1「可点击即可聚焦」/ 阶段 2):整卡是热区,
|
||
只有 onClick 时 Tab 走不到它,键盘用户点不中任何一镜。
|
||
为什么不顺手补 role="button":button 的 Children Presentational 规则
|
||
会把卡内那颗「选择镜头 N」勾选框和底部三颗动作按钮一起从无障碍树里抹掉,
|
||
补了焦点反而少三个控件,比不改更糟。所以留 <article>,自己接键。
|
||
Enter / Space 都算「打开这一镜的详情」(与鼠标点整卡同义);
|
||
守卫 target === currentTarget:卡内控件的 keydown 会冒泡到这里,
|
||
不守卫就会在「回车按卡内的删除/复制」时顺手把检查器也打开。
|
||
aria-label 只报「哪一镜」不报标题:article 的正文不是 presentational,
|
||
标题紧跟着就会被读第二遍;「分镜详情」这个词与关闭按钮
|
||
(CloseButton / Scrim 的「关闭分镜详情」)用同一个说法,来回不换名。 */
|
||
tabIndex={0}
|
||
aria-label={'打开分镜详情:镜头 ' + (s.code || s.order_index)}
|
||
aria-current={selected ? 'true' : undefined}
|
||
onKeyDown={(ev) => {
|
||
if (ev.target !== ev.currentTarget) return
|
||
if (ev.key !== 'Enter' && ev.key !== ' ') return
|
||
ev.preventDefault()
|
||
onSelect()
|
||
}}
|
||
onDragStart={onDragStart}
|
||
onDragOver={(ev) => { ev.preventDefault(); onDragOverItem() }}
|
||
onDragEnd={onDragEnd}
|
||
onDrop={(ev) => { ev.preventDefault(); onDropItem() }}
|
||
onClick={onSelect}
|
||
className={cn(SHOT_CARD,
|
||
/* 顺序 = 基础 → 选中 → 拖拽落点 → 勾选:tailwind-merge 留最后一条,
|
||
「勾选」是横跨视图的批量态,切到分镜表时它必须还看得见,
|
||
所以让 picked 最后写,绝不被「当前镜头」覆盖掉。 */
|
||
selected && 'border-primary-active shadow-[inset_0_0_0_1px_var(--ant-color-primary-border),0_8px_22px_-14px_var(--ant-color-fill-secondary)]',
|
||
draggedOver && 'border-info border-dashed',
|
||
picked && 'border-primary-border bg-primary-bg shadow-[inset_0_0_0_1px_var(--ant-color-primary-border)]')}>
|
||
{/* 卡片有两块热区,探针各认一块(见 scripts/ui/audit.py 的 OVERLAYS):
|
||
data-shot-preview = 缩略图,点它是「预览这一镜的媒体」(灯箱);
|
||
data-shot-select = 标题行,点它是「选中这一镜」(检查器)。
|
||
为什么必须分开:探针点的是元素几何中心,窄屏卡片中心正好落在缩略图上,
|
||
拿整卡当入口会打开灯箱,检查器那条用例就永远量不到面板。 */}
|
||
<div data-shot-preview className={cn(SHOT_THUMB, PULSE_CLS[cardPulse(s)])}>
|
||
{s.output_url ? (
|
||
<video src={s.output_url} muted preload="none" loop
|
||
poster={thumbUrl(s.keyframe_url || s.output_url, 384)}
|
||
onClick={(ev) => { ev.stopPropagation(); onPreview('output') }}
|
||
onMouseEnter={(ev) => { ev.currentTarget.play().catch(() => {}) }}
|
||
onMouseLeave={(ev) => ev.currentTarget.pause()} />
|
||
) : s.keyframe_url ? (
|
||
<img src={thumbUrl(s.keyframe_url, 384)} alt={s.title} loading="lazy"
|
||
onClick={(ev) => { ev.stopPropagation(); onPreview('keyframe') }} />
|
||
) : (
|
||
<span className={THUMB_PLATE}>无关键帧</span>
|
||
)}
|
||
<span className={THUMB_ORDINAL}>{String(s.order_index).padStart(2, '0')}</span>
|
||
<span className={THUMB_DUR}>{s.duration}s</span>
|
||
<Checkbox checked={picked} title="勾选后可批量操作(快捷键 X)"
|
||
className="absolute top-[8px] right-[8px] cursor-pointer"
|
||
aria-label={`选择镜头 ${s.code || s.order_index}`}
|
||
onClick={(ev) => { ev.stopPropagation(); onCheck(ev.shiftKey) }} />
|
||
{s.output_url
|
||
? <Tag size="sm" tone="ok" className="absolute bottom-2 left-[7px]">已生成</Tag>
|
||
: (s.mode !== 't2v' && !s.keyframe_url
|
||
? <Tag size="sm" tone="warn" className="absolute bottom-2 left-[7px]">缺关键帧</Tag>
|
||
: null)}
|
||
</div>
|
||
|
||
<div className={SHOT_BODY}>
|
||
{/* 状态标签不许压扁:这行是 flex,两个子项默认按比例一起收缩,
|
||
标题一长就把右侧 Status 咬成 35px 的「已…」(2026-11 探针实测 7 处/主题)。
|
||
两件事各治一半:
|
||
· <b> 加 min-w-0——它默认 min-width:auto,长标题的 min-content 顶住了收缩,
|
||
差额没处去,只能从标签身上咬;放开之后标题自己吸收(折行规则没动)。
|
||
· 外层 span flex-none——标签不参与收缩,42px 起底。为什么不直接把
|
||
flex-none 写给 <Status>:kit 的 Tag 收了 className 却没并进 cn(),
|
||
写上去是空转(D16,见 docs/NEX-对照与例外.md §6),修好之后这层 span 可撤。
|
||
卡片宽度、栅格、标题行数都不动;标签兜底的 title 仍然保留(窄到连 42px
|
||
都给不出时,读 title)。 */}
|
||
<div className="flex min-w-0 items-start justify-between gap-2">
|
||
<b data-shot-select className="min-w-0 text-xs leading-snug">{s.title || '未命名镜头'}</b>
|
||
<span className="flex-none"><Status value={s.status} /></span>
|
||
</div>
|
||
<p className="m-0 line-clamp-2 text-xs leading-normal text-text-tertiary">{s.description || '未填写画面描述'}</p>
|
||
{s.dialogue
|
||
? (
|
||
<p className="m-0 text-xs italic leading-normal text-text-secondary">「{s.dialogue}」
|
||
<span className={MUTED}> — {s.speaker_name || '未指定说话人'}</span>
|
||
</p>
|
||
)
|
||
: null}
|
||
<div className={SHOT_META}>
|
||
<Mono>{s.code}</Mono>
|
||
<span>{opt('shot_size', s.shot_size)}</span>
|
||
<span>{opt('camera_movement', s.camera_movement)}</span>
|
||
<span>{opt('mode', s.mode)}</span>
|
||
{s.qc_score !== null && s.qc_score !== undefined
|
||
? <Tag tone={s.qc_score >= 80 ? 'ok' : 'warn'}>QC {s.qc_score.toFixed(0)}</Tag>
|
||
: null}
|
||
{badge
|
||
? <Tag tone={badge.tone === 'ok' ? 'ok' : (badge.tone === 'warn' ? 'warn' : 'info')} title={s.review_notes || ''}>{badge.text}</Tag>
|
||
: (s.review_state === 'fail' ? <Tag tone="bad">已驳回</Tag> : null)}
|
||
</div>
|
||
<div className={SHOT_META}>
|
||
{s.characters?.length ? <Tag tone="info">{s.characters.map((c: any) => c.name).join('、')}</Tag> : null}
|
||
{s.scenes?.length ? <Tag>{s.scenes.map((c: any) => c.name).join('、')}</Tag> : null}
|
||
{!s.characters?.length ? <Tag tone="warn">未绑人物</Tag> : null}
|
||
</div>
|
||
{!s.ready ? (
|
||
<div className={SHOT_ISSUES}>
|
||
{issueOf(s, 'error').slice(0, 2).map((i: any, k: number) => (
|
||
<span key={`e${k}`} className="text-error">{i.message}</span>
|
||
))}
|
||
{issueOf(s, 'warning').slice(0, 1).map((i: any, k: number) => (
|
||
<span key={`w${k}`} className={MUTED}><IconText icon={<IconWarn />}>{i.message}</IconText></span>
|
||
))}
|
||
</div>
|
||
) : null}
|
||
<div className={SHOT_FOOT} onClick={(ev) => ev.stopPropagation()}>
|
||
<Button type="primary" size="sm" onClick={onText} title="直接改这一镜的画面描述与台词" icon={<IconEdit />}>改文案</Button>
|
||
<LinkButton to={dispatchLink(projectId, s)} size="sm"
|
||
title={s.output_url ? '已有产物:到调度中心只重做这一镜' : '到调度中心生成这一镜'}
|
||
icon={s.output_url ? <IconReload /> : <IconPlayCircle />}>
|
||
{s.output_url ? '重生成' : '生成'}
|
||
</LinkButton>
|
||
<BarRight>
|
||
<Link to={`/projects/${projectId}/review?shot=${s.id}`} className={LINK_CLS}>审核</Link>
|
||
{/* 这一条原先在 1440 就被劈开过(闸门 §15.11):左端「生成/重生成」把宽度吃掉之后
|
||
BarRight 只剩 89px,「审核 + 复制」占一行、删除单独掉到第二行。
|
||
复制 / 删除是这一镜的对象级操作,粘成一组整块换行。 */}
|
||
<ActionGroup>
|
||
<Button size="sm" disabled={busy} onClick={onDuplicate} title="复制这一镜" aria-label="复制这一镜" icon={<IconCopy />} />
|
||
<Button type="text" danger title="删除这一镜" aria-label="删除这一镜" onClick={onRemove} icon={<IconDelete />} />
|
||
</ActionGroup>
|
||
</BarRight>
|
||
</div>
|
||
</div>
|
||
</article>
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 一句台词(.linedlg-row):行号 / 说话人 / 台词 / 删除四个控件排在同一条中心线上。
|
||
* 说话人缺失时下面拖一行橙色提示(.linehint),位置对齐台词框左沿(22 + 6 + 128 = 156px)。
|
||
*/
|
||
function DialogueRow({ index, row, total, characters, issue, onSpeaker, onText, onRemove }: {
|
||
index: number
|
||
row: DialogueLine
|
||
total: number
|
||
characters: any[]
|
||
issue: string
|
||
onSpeaker: (next: number | null) => void
|
||
onText: (next: string) => void
|
||
onRemove: () => void
|
||
}) {
|
||
return (
|
||
<div className="flex min-w-0 flex-col gap-0.5">
|
||
<div className={LINE_ROW}>
|
||
<span className="grid place-items-center text-text-quaternary"><Mono>{index + 1}</Mono></span>
|
||
<Select value={row.character_id} ariaLabel="说话人" onChange={onSpeaker}
|
||
options={[{ value: null, label: '未指定' },
|
||
...characters.map((c) => ({ value: c.id, label: c.name }))]} />
|
||
<TextArea rows={2} value={row.text} placeholder={total > 1 ? `第 ${index + 1} 句台词` : '这一镜的台词,留空表示无台词'} onChange={(e) => onText(e.target.value)} />
|
||
<Button type="text" danger htmlType="button" title="删除这一句" aria-label="删除这一句" onClick={onRemove} icon={<IconDelete />} />
|
||
</div>
|
||
{issue ? <small className="ml-[156px] text-xs leading-normal text-warning-hover"><IconText icon={<IconWarn />}>{issue}</IconText></small> : null}
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/** 一个音效(.linedlg-row.sfx):素材 / 入点 / 音量 / 删除;数值留空按 0 落库 */
|
||
function SfxRowView({ row, assets, onPick, onPatch, onRemove }: {
|
||
row: SfxRow
|
||
assets: any[]
|
||
onPick: (assetId: number | null) => void
|
||
onPatch: (patch: Record<string, any>) => void
|
||
onRemove: () => void
|
||
}) {
|
||
return (
|
||
<div className={SFX_ROW}>
|
||
<Select value={row.asset_id} ariaLabel="音效素材"
|
||
onChange={(next) => onPick(next === undefined ? null : next)}
|
||
options={[{ value: null, label: '选择音效' },
|
||
...assets.map((a) => ({ value: a.id, label: a.name }))]} />
|
||
<NumberInput step="100" min="0" value={row.offset_ms ?? 0} title="入点(毫秒)" aria-label="入点毫秒" onChange={ (v) => onPatch({ offset_ms: numOr(v, 0) })} />
|
||
<NumberInput step="1" value={row.gain_db ?? 0} title="音量(dB)" aria-label="音量分贝" onChange={ (v) => onPatch({ gain_db: numOr(v, 0) })} />
|
||
<Button type="text" danger htmlType="button" title="删除这个音效" aria-label="删除这个音效" onClick={onRemove} icon={<IconDelete />} />
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/** 镜头素材行(.sb-asset):缩略图 + 名称 + 版本元信息;点缩略图进全局预览器切历史版本 */
|
||
function AssetRow({ asset: a, queue, index, onPreview }: {
|
||
asset: any; queue: MediaItem[]; index: number; onPreview: () => void
|
||
}) {
|
||
return (
|
||
<div className="flex min-w-0 items-center gap-2 rounded-lg border border-fill-secondary bg-bg-container p-2 text-xs">
|
||
<MediaThumb item={fromAsset(a)} queue={queue} index={index} width="62px" size="xs"
|
||
inlineAudio={false} className="flex-none" title={`放大预览:${a.name}`} />
|
||
<div className="min-w-0 flex-1">
|
||
<b>{a.kind_label || a.kind}</b> <span className={MUTED}>{a.name}</span>
|
||
<div className={MUTED_MONO}>
|
||
v{a.version} · {fmtAgo(a.versions?.[0]?.created_at)}
|
||
{a.width && a.height ? ` · ${a.width}×${a.height}` : ''}
|
||
</div>
|
||
</div>
|
||
{a.metadata?.model ? <Tag tone="info">{a.metadata.model}</Tag> : null}
|
||
<Button icon={<IconEye />} size="sm" onClick={onPreview}>预览</Button>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/** 提示词历史版本(.cardrow):正文截到 200 字;「回填」只灌回表单,仍要点保存才产生新版本 */
|
||
function RevisionCard({ rev: r, onUse }: { rev: any; onUse: () => void }) {
|
||
return (
|
||
<div className={CARD_ROW}>
|
||
<div className="min-w-0 flex-1">
|
||
<h4>
|
||
#{r.id} <Tag tone={r.applied ? 'ok' : 'default'}>{r.applied ? '生效中' : '历史'}</Tag>
|
||
<span className={MUTED}>{r.actor} · {r.reason}</span>
|
||
</h4>
|
||
<p>{(r.prompt || '').slice(0, 200)}…</p>
|
||
<small className={MUTED}>{fmtTime(r.created_at)}</small>
|
||
</div>
|
||
<Button icon={<IconCheck />} size="sm" onClick={onUse}>回填</Button>
|
||
</div>
|
||
)
|
||
}
|