cmvr-visual/frontend/src/components/EditableProduction.vue

1961 lines
67 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import { isDialogueManifest } from '../domain/creation/continuity'
import { upgradeContinuity } from '../domain/creation/continuity'
import { useCapabilitiesStore } from '../stores/capabilities'
import { computed, onBeforeUnmount, ref, watch } from 'vue'
import { captionSrtUrl } from '../api/editors'
import { api, errorMessage } from '../api'
import { getSessionGeneration } from '../api/client'
import { useAuthStore } from '../stores/auth'
import { useEditableProduction } from '../composables/editableProduction'
import {
editorId,
editorFrames,
moveEditorShot,
removeEditorShot,
removeEditorSegment,
addEditorShot,
setEditorShotDuration,
setEditorSegmentSpeed,
canMoveEditorShot,
} from '../domain/creation/editor'
import { createShot } from '../domain/stories/rules'
import { createWorkflowShot } from '../domain/workflows/timeline'
import {
H3_VIDEO_PROFILE,
H3_NATIVE_AV_TP2_PROFILE,
H3_TP2_VIDEO_PROFILE,
H3_TP2_UNAVAILABLE_REASON,
LEGACY_VIDEO_PROFILE,
videoProfileCapability,
nativeStoryVideoCapability,
nativeCanvasIssue,
nativeLandscapeOnly,
H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION,
H3_NATIVE_AV_PROFILE,
} from '../domain/creation/videoProfile'
import type { EditorDTO, EditorCue, EditorOutputGoal } from '../types/editors'
import type { Asset, AssetKind } from '../types/assets'
import type { RunDTO } from '../types/workflows'
import AssetPicker from './AssetPicker.vue'
import AssetPreview from './AssetPreview.vue'
import RunCard from './RunCard.vue'
import StoryBaselineBoard from './studio/StoryBaselineBoard.vue'
import StoryFilmPreview from './studio/StoryFilmPreview.vue'
import StoryShotEditor from './studio/StoryShotEditor.vue'
import CutForkPreview from './studio/CutForkPreview.vue'
import TurnReviewPanel from './studio/TurnReviewPanel.vue'
import RhythmCaptions from './studio/RhythmCaptions.vue'
import DialogueEditor from './studio/DialogueEditor.vue'
import {
canChangeSequence,
NATIVE_DIALOGUE_UNAVAILABLE,
nativeUtterancesForShot,
twoPersonCertificateIssue,
} from '../domain/creation/dialogue'
import { secondsToSamples, samplesToSeconds } from '../domain/creation/nativeTiming'
const props = withDefaults(
defineProps<{
draftId: string
draftName?: string
outputFolderId?: string | null
section?: 'baseline' | 'shots' | 'render' | 'all'
manualDialogue?: boolean
}>(),
{ section: 'all' },
)
const emit = defineEmits<{
dirty: [value: boolean]
saved: [value: EditorDTO, submittedName?: string]
loaded: [value: EditorDTO]
forked: [draftId: string]
}>()
const editor = useEditableProduction(
() => props.draftId,
() => props.outputFolderId,
() => props.draftName,
)
const { dto, manifest, busy, notice, dirty, plan, snapshot, executionMode } = editor
const capabilities = useCapabilitiesStore()
const dialogueManifest = computed(() =>
isDialogueManifest(manifest.value) ? manifest.value : undefined,
)
const nativeDialogue = computed(
() => dialogueManifest.value?.spec.dialogue.generation === 'native_av',
)
const nativeAudioConflict = computed(
() =>
nativeDialogue.value &&
!!manifest.value &&
(manifest.value.audio.mode !== 'silent' ||
dialogueManifest.value?.audio.mix_mode !== 'composed'),
)
const nativeBaseAvailable = computed(() => capabilities.dialogue?.native_av?.available === true)
const nativeCanvasReason = computed(() => {
if (!nativeDialogue.value || !nativeBaseAvailable.value || !dialogueManifest.value) return
const canvases = capabilities
.forTask('video.generate')
?.video_profiles?.filter(
(profile) =>
[H3_NATIVE_AV_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(profile.profile) &&
profile.available === true,
)
.flatMap((profile) => profile.canvases ?? [])
return nativeCanvasIssue(dialogueManifest.value.spec.profile, canvases)
})
const dialogueAvailable = computed(() => nativeBaseAvailable.value && !nativeCanvasReason.value)
const dialogueGenerationReason = computed(() =>
dialogueManifest.value?.spec.dialogue.generation !== 'native_av'
? '请先升级为H3原生对白,再保存当前修改。'
: nativeCanvasReason.value ||
capabilities.dialogue?.native_av?.reason ||
NATIVE_DIALOGUE_UNAVAILABLE,
)
const dialogueNeedsCertification = computed(() =>
nativeDialogue.value
? !dialogueAvailable.value
: !!dialogueManifest.value?.spec.dialogue.enabled &&
dialogueManifest.value.spec.dialogue.utterances.length > 0 &&
(dialogueManifest.value.spec.dialogue.generation !== 'native_av' || !dialogueAvailable.value),
)
const nativeFilmIssue = computed(() => nativeGenerationIssue('film', []))
const filmBlocked = computed(() => {
if (nativeDialogue.value) return nativeAudioConflict.value
const m = dialogueManifest.value
return (
!!m?.spec.dialogue.enabled &&
!!m.spec.dialogue.utterances.length &&
(m.audio.mix_mode === 'manual_mix' || m.audio.mode === 'manual_track')
)
})
const remixGoal = computed(() => (capabilities.editorV4 ? 'mix_film' : 'film'))
const remixBlocked = computed(
() =>
busy.value ||
filmBlocked.value ||
(remixGoal.value === 'film' && (dialogueNeedsCertification.value || !!nativeFilmIssue.value)),
)
const sourceOnlyGoal = (goal: EditorOutputGoal) =>
goal === 'caption_film' || goal === 'caption_inspect' || goal === 'mix_film'
const visibleLimit = computed(() => capabilities.dialogue?.native_av?.max_visible_speakers ?? 1)
const preparedForks = ref<Record<string, string>>({})
let forkEpoch = 0
const tp2Capability = computed(() =>
videoProfileCapability({ profile: H3_TP2_VIDEO_PROFILE }, capabilities.forTask('video.generate')),
)
const nativeTp2Capability = computed(() =>
capabilities
.forTask('video.generate')
?.video_profiles?.find((profile) => profile.profile === H3_NATIVE_AV_TP2_PROFILE),
)
const nativeTp2Available = computed(
() =>
nativeBaseAvailable.value &&
!!manifest.value &&
nativeStoryVideoCapability(
{ profile: H3_NATIVE_AV_TP2_PROFILE },
manifest.value.spec.profile,
capabilities.forTask('video.generate'),
)?.available === true,
)
const tp2Available = computed(() => tp2Capability.value?.available === true)
const tp2Reason = computed(() => tp2Capability.value?.reason || H3_TP2_UNAVAILABLE_REASON)
async function enableContinuity() {
const m = manifest.value
if (!capabilities.continuity || !m || !upgradeContinuity(m)) return
await save()
}
const auth = useAuthStore(),
index = ref(0),
history = ref<RunDTO[]>([]),
historyPage = ref(1),
historyTotal = ref(0),
historyLoading = ref(false),
preview = ref<Asset | null>(null),
picker = ref(false),
pickerKey = ref(''),
pickerKinds = ref<AssetKind[]>(['image'])
let dialoguePicker: { draftId: string; version: number; session: number } | undefined
const shot = computed(() => manifest.value?.spec.shots[index.value]),
shotId = computed(() => manifest.value?.shot_ids[index.value] || '')
const previewCutShot = ref('')
watch(
() => [props.draftId, dto.value?.version, shotId.value, auth.user?.id],
() => {
previewCutShot.value = ''
},
)
const dialogueShot = computed(() => dialogueManifest.value?.spec.shots[index.value])
const total = computed(() => (manifest.value ? editorFrames(manifest.value) : 0))
const selectedSegments = computed(
() => manifest.value?.audio.segments.filter((s) => s.shot_id === shotId.value) || [],
)
let refreshGeneration = 0,
runSelection = 0,
historyToken = 0
let pendingRefresh: { key: string; promise: Promise<void> } | undefined
function shouldPoll(run: RunDTO) {
return (
['queued', 'running', 'cancelling', 'pausing'].includes(run.state) ||
(run.state === 'succeeded' && run.apply_state === 'pending')
)
}
function mergeHistory(items: RunDTO[]) {
const merged = new Map([...history.value, ...items].map((r) => [r.id, r]))
history.value = [...merged.values()].sort((a, b) => b.created_at.localeCompare(a.created_at))
}
function runHistory(id: string, page?: number) {
const filters = { ...(page ? { page } : {}), page_size: 100 }
return manifest.value?.source_kind === 'story'
? api.storyRuns(id, filters)
: api.runs({ draft_id: id, ...filters })
}
async function loadMoreHistory() {
if (historyLoading.value || history.value.length >= historyTotal.value) return
const token = ++historyToken,
id = props.draftId,
session = getSessionGeneration(),
page = historyPage.value + 1
historyLoading.value = true
try {
const value = await runHistory(id, page)
if (token === historyToken && session === getSessionGeneration() && id === props.draftId) {
mergeHistory(value.items)
historyPage.value = page
historyTotal.value = value.total
}
} catch (e) {
if (token === historyToken && session === getSessionGeneration()) notice.value = errorMessage(e)
} finally {
if (token === historyToken) historyLoading.value = false
}
}
function refresh() {
const generation = refreshGeneration,
id = props.draftId,
session = getSessionGeneration()
const key = `${generation}:${session}:${id}`
if (pendingRefresh?.key === key) return pendingRefresh.promise
const isCurrent = () =>
generation === refreshGeneration && id === props.draftId && session === getSessionGeneration()
const promise = refreshDraft(id, isCurrent).finally(() => {
if (pendingRefresh?.promise === promise) pendingRefresh = undefined
})
pendingRefresh = { key, promise }
return promise
}
async function refreshDraft(id: string, isCurrent: () => boolean) {
const acceptEditor = editor.refreshGuard()
const selection = runSelection
try {
const result = await runHistory(id)
if (!isCurrent()) return
if (historyPage.value === 1) history.value = result.items
else mergeHistory(result.items)
historyTotal.value = result.total
if (selection !== runSelection) return
const activeId =
snapshot.value?.run.id ||
history.value.find((r) => shouldPoll(r) || ['blocked', 'paused'].includes(r.state))?.id
if (activeId) {
const isSelected = () =>
isCurrent() &&
selection === runSelection &&
(!snapshot.value || snapshot.value.run.id === activeId)
const current = await api.run(activeId)
if (!isSelected()) return
snapshot.value = current
if (current.run.apply_state === 'applied' && !dirty.value) {
const sent = JSON.stringify(manifest.value),
value = await api.editor(id)
if (isSelected() && sent === JSON.stringify(manifest.value)) {
if (acceptEditor(value)) emit('saved', value)
}
}
}
} catch (e) {
if (isCurrent() && selection === runSelection) notice.value = errorMessage(e)
}
}
async function openRun(id: string) {
const selection = ++runSelection,
generation = refreshGeneration,
session = getSessionGeneration(),
draftId = props.draftId
const isCurrent = () =>
selection === runSelection &&
generation === refreshGeneration &&
session === getSessionGeneration() &&
draftId === props.draftId
try {
const value = await api.run(id)
if (isCurrent()) snapshot.value = value
} catch (e) {
if (isCurrent()) notice.value = errorMessage(e)
}
}
async function syncFromServer() {
if (busy.value || dirty.value) return
const accept = editor.refreshGuard(),
id = props.draftId,
session = getSessionGeneration()
try {
const value = await api.editor(id)
if (accept(value)) {
emit('loaded', value)
return value
}
} catch (error) {
if (id === props.draftId && session === getSessionGeneration())
notice.value = errorMessage(error)
}
}
async function save() {
if (busy.value) return
if (manifest.value?.schema_version === 4 && !capabilities.editorV4) {
notice.value = '此草稿需要支持编辑器 V4 的服务才能保存。'
return
}
const session = getSessionGeneration(),
id = props.draftId,
submittedName = props.draftName
const current = () => session === getSessionGeneration() && id === props.draftId
busy.value = true
try {
const value = await editor.save()
if (value) emit('saved', value, submittedName)
} catch (e) {
if (current()) notice.value = errorMessage(e)
} finally {
if (current()) busy.value = false
}
}
async function generate(goal: EditorOutputGoal, targets: string[] = [], force = false) {
if (!manifest.value || busy.value) return
if (!capabilities.editorV4 && (manifest.value.schema_version === 4 || sourceOnlyGoal(goal))) {
notice.value = '此操作需要支持编辑器 V4 的服务。'
return
}
if (
nativeDialogue.value &&
targets.some((target) => target === 'script' || target.startsWith('audio:'))
) {
notice.value = 'H3原生对白不使用独立旁白生成,请在镜头对白中添加画外台词。'
return
}
if (
dialogueManifest.value &&
targets.some((target) =>
/^(speech|normalized_speech|base_video|synced_video|face_tracks):/.test(target),
)
) {
notice.value = '历史独立配音和口型生成已停用,请升级为H3原生对白。'
return
}
if (
!sourceOnlyGoal(goal) &&
(!targets.length || targets.some((target) => /^(video|native_alignment):/.test(target))) &&
dialogueNeedsCertification.value
) {
notice.value = dialogueGenerationReason.value
return
}
const nativeIssue = nativeGenerationIssue(goal, targets)
if (nativeIssue) {
notice.value = nativeIssue
return
}
if (goal === 'film' && filmBlocked.value) {
notice.value = nativeDialogue.value
? '请先关闭历史独立旁白及成品音轨;画外台词请在镜头对白中编写。'
: '请切回对白自动混音,或在成片设置中暂停对白。'
return
}
if (
manifest.value.schema_version !== 1 &&
total.value > (capabilities.continuity?.max_total_frames ?? 7200)
) {
notice.value = '成片贡献帧超过服务端上限'
return
}
if (
(goal === 'caption_film' || targets.includes('captions')) &&
manifest.value.captions.mode === 'none'
) {
notice.value = '请先启用字幕模式,再更新字幕并成片'
return
}
if (targets.some((t) => t === 'script' || t.startsWith('audio:')))
manifest.value.audio.mode = 'generated_narration'
const submittedName = props.draftName
const saved = await editor.generate(goal, targets, force)
if (saved) emit('saved', saved, submittedName)
await refresh()
}
function nativeGenerationIssue(goal: EditorOutputGoal, targets: string[]) {
const m = dialogueManifest.value
if (sourceOnlyGoal(goal) || !nativeDialogue.value || !m) return
if (goal !== 'film' && targets.length && !targets.some((target) => target.startsWith('video:')))
return
if (!dialogueAvailable.value) return dialogueGenerationReason.value
const selected =
goal === 'film' || !targets.length
? m.spec.shots
: m.spec.shots.filter((shot) => targets.includes('video:' + shot.id))
for (const current of selected) {
const contract = twoPersonCertificateIssue(
current,
nativeUtterancesForShot(m.spec, current),
capabilities.dialogue?.native_av?.two_person_turns,
)
if (contract) return contract
const capability = nativeStoryVideoCapability(
current.video_parameters,
m.spec.profile,
capabilities.forTask('video.generate'),
)
if (capability?.available !== true)
return capability?.reason || '当前镜头原生配置和画布尚未通过认证,暂不可生成。'
}
}
function runDialogueTarget(kind: 'video' | 'native_alignment', id: string, force: boolean) {
const m = dialogueManifest.value
if (!m || !['video', 'native_alignment'].includes(kind)) {
notice.value = '历史独立配音和口型生成已停用,请使用H3原生对白。'
return
}
if (m.spec.dialogue.generation !== 'native_av' || !dialogueAvailable.value) {
notice.value = dialogueGenerationReason.value
return
}
if (!m.spec.shots.some((shot) => shot.id === id)) return
return generate('media', [`${kind}:${id}`], force)
}
function disableLegacyNarration() {
const m = dialogueManifest.value
if (!nativeDialogue.value || !m || busy.value) return
// 只暂停旧声音模式;旧文案、音轨、素材和背景音乐仍在当前版本中保留。
m.audio.mode = 'silent'
m.audio.mix_mode = 'composed'
}
function setMixMode(mode: string) {
const audio = dialogueManifest.value?.audio
if (!audio) return
audio.mix_mode = mode === 'manual_mix' ? 'manual_mix' : 'composed'
if (audio.mix_mode === 'composed' && audio.mode === 'manual_track') audio.mode = 'silent'
if (audio.mix_mode === 'manual_mix' && audio.track) audio.mode = 'manual_track'
}
async function restore(id: string, apply = false) {
await editor.restore(id, apply)
if (dto.value) emit('saved', dto.value)
}
function canForkPrepared(run: Pick<RunDTO, 'draft_id' | 'state' | 'production_materialized'>) {
return (
!!dialogueManifest.value &&
run.draft_id === props.draftId &&
run.production_materialized === true &&
['blocked', 'failed', 'cancelled'].includes(run.state)
)
}
async function forkPrepared(run: RunDTO) {
if (
!canForkPrepared(run) ||
!dto.value ||
busy.value ||
dirty.value ||
preparedForks.value[run.id]
)
return
const draftId = props.draftId,
version = dto.value.version,
session = getSessionGeneration(),
epoch = forkEpoch
const current = () =>
draftId === props.draftId && session === getSessionGeneration() && epoch === forkEpoch
const name = Array.from(dto.value.name.trim()).slice(0, 252).join('') + '准备稿'
busy.value = true
notice.value = ''
try {
const result = await api.forkPreparedDialogue(draftId, version, run.id, name)
if (!current()) return
if (
!result.draft_id ||
result.draft_id === draftId ||
result.origin?.source_draft_id !== draftId ||
result.origin.source_run_id !== run.id ||
!isDialogueManifest(result.manifest) ||
result.manifest.base_run_id !== null
)
throw new Error('准备稿返回的来源或版本无效,请重新读取后检查')
preparedForks.value[run.id] = result.draft_id
// 源故事可能在请求期间又有编辑。保留副本链接,避免自动离开造成修改丢失。
if (!dirty.value) emit('forked', result.draft_id)
} catch (error) {
if (current()) notice.value = errorMessage(error)
} finally {
if (current()) busy.value = false
}
}
function add() {
if (!manifest.value) return
const m = manifest.value
if (m.schema_version !== 1 && m.shot_ids.length >= (capabilities.continuity?.max_shots ?? 60)) {
notice.value = '制作已达镜头数上限'
return
}
const s =
m.source_kind === 'story'
? createShot(m.spec.schema_version)
: createWorkflowShot(m.spec.shots.length)
const id = 'id' in s ? s.id : editorId()
addEditorShot(m, s, id)
if (!isDialogueManifest(m)) m.audio.segments.push({ id: editorId(), shot_id: id, text: '' })
index.value = m.shot_ids.length - 1
}
function remove() {
if (!manifest.value || manifest.value.shot_ids.length <= 1) return
if (removeEditorShot(manifest.value, index.value)) index.value = Math.max(0, index.value - 1)
}
function move(delta: number) {
if (!manifest.value) return
const next = index.value + delta
if (next < 0 || next >= manifest.value.shot_ids.length) return
if (moveEditorShot(manifest.value, index.value, next)) index.value = next
}
function pick(key: string, kind: AssetKind) {
dialoguePicker =
dialogueManifest.value && dto.value
? { draftId: props.draftId, version: dto.value.version, session: getSessionGeneration() }
: undefined
pickerKey.value = key
pickerKinds.value = [kind]
picker.value = true
}
const audioFields = [
['offset_sample', '偏移(秒)'],
['source_start_sample', '源起点(秒)'],
['source_end_sample', '源终点(秒)'],
['gain_db', '增益 dB'],
['fade_in_samples', '淡入(秒)'],
['fade_out_samples', '淡出(秒)'],
] as const
function setSample(
part: import('../types/editors').AudioPosition,
field: (typeof audioFields)[number][0],
value: string,
) {
if (value === '') delete part[field]
else part[field] = field === 'gain_db' ? Number(value) : secondsToSamples(Number(value))
}
function setAnchor(part: import('../types/editors').AudioPosition, value: string) {
if (!manifest.value) return
delete part.shot_id
delete part.scene_id
if (value === 'shot') {
part.anchor = 'shot'
part.shot_id = shotId.value
} else if (value === 'scene' && 'scenes' in manifest.value.spec) {
part.anchor = 'scene'
part.scene_id = manifest.value.spec.scenes[0]?.id
} else part.anchor = 'absolute'
}
function selected(asset: Asset) {
const m = manifest.value
if (!m) return
if (
isDialogueManifest(m) &&
(dialoguePicker?.draftId !== props.draftId ||
dialoguePicker.version !== dto.value?.version ||
dialoguePicker.session !== getSessionGeneration())
) {
notice.value = '草稿版本已更新,请重新选择素材。'
return
}
const [role, id] = pickerKey.value.split(':')
if (role === 'face_reference_asset_id' || role === 'voice_reference_asset_id') {
if (
!isDialogueManifest(m) ||
m.spec.schema_version !== 6 ||
asset.kind !== (role === 'face_reference_asset_id' ? 'image' : 'audio')
)
return
const speaker = m.spec.dialogue.speakers.find((s) => s.id === id)
if (!speaker) return
if (
role === 'face_reference_asset_id' &&
!m.spec.entities
.find((e) => e.id === speaker.entity_id)
?.reference_asset_ids.includes(asset.id)
) {
notice.value = '请在该人物的独立参考图中选择参考脸。'
return
}
speaker[role] = asset.id
} else if (role === 'voice' || role === 'utterance') {
if (!isDialogueManifest(m) || asset.kind !== 'audio') return
if (role === 'voice') {
const speaker = m.spec.dialogue.speakers.find((item) => item.id === id)
if (!speaker) return
speaker.voice.reference_asset_id = asset.id
speaker.voice.reference_text = ''
} else {
const line = m.spec.dialogue.utterances.find((item) => item.id === id)
if (!line || line.locked) return
Object.assign(line, {
source: 'asset',
asset_id: asset.id,
source_start_sample: 0,
source_end_sample: null,
})
}
} else if (pickerKey.value === 'bgm' || pickerKey.value === 'sfx') {
m.audio.layers ??= []
if (m.audio.layers.length >= 32) return
m.audio.layers.push({
id: editorId(),
asset_id: asset.id,
role: pickerKey.value,
anchor: 'absolute',
offset_sample: 0,
})
} else if (pickerKey.value === 'track') {
m.audio.track =
m.schema_version !== 1
? {
asset_id: asset.id,
sample_rate: 48000,
source_start_sample: 0,
source_end_sample: Math.round((asset.duration_seconds || total.value / 24) * 48000),
offset_sample: 0,
short_policy: 'silence',
}
: {
asset_id: asset.id,
source_start_ms: 0,
source_end_ms: Math.round((asset.duration_seconds || total.value / 24) * 1000),
offset_frame: 0,
short_policy: 'silence',
}
m.audio.mode = 'manual_track'
if (isDialogueManifest(m)) m.audio.mix_mode = 'manual_mix'
} else
m.bindings[pickerKey.value] = {
asset_id: asset.id,
kind: asset.kind,
source: 'manual',
locked: true,
}
if (dto.value && !dto.value.assets.some((a) => a.id === asset.id)) dto.value.assets.push(asset)
}
function assetFor(key: string) {
return dto.value?.assets.find((a) => a.id === manifest.value?.bindings[key]?.asset_id)
}
function addCue() {
manifest.value?.captions.cues.push({
id: editorId(),
anchor: 'shot',
shot_id: shotId.value,
start_frame: 0,
end_frame: 24,
text: '',
text_override: true,
timing_override: true,
})
}
function anchor(c: EditorCue) {
c.timing_override = true
delete c.shot_id
delete c.segment_id
delete c.utterance_id
if (c.anchor === 'shot') c.shot_id = shotId.value
if (c.anchor === 'audio_segment') c.segment_id = manifest.value?.audio.segments[0]?.id
if (c.anchor === 'utterance')
c.utterance_id = dialogueManifest.value?.spec.dialogue.utterances[0]?.id
}
function beforeUnload(event: BeforeUnloadEvent) {
if (dirty.value) {
event.preventDefault()
event.returnValue = ''
}
}
if (typeof window !== 'undefined') window.addEventListener('beforeunload', beforeUnload)
watch(dirty, (value) => emit('dirty', value), { immediate: true })
watch(
() => props.draftId,
async () => {
const generation = ++refreshGeneration
forkEpoch++
preparedForks.value = {}
historyToken++
historyPage.value = 1
historyTotal.value = 0
historyLoading.value = false
history.value = []
index.value = 0
await editor.load()
if (generation !== refreshGeneration) return
if (dto.value) emit('loaded', dto.value)
await refresh()
},
{ immediate: true },
)
watch(
() => auth.user,
() => {
forkEpoch++
preparedForks.value = {}
refreshGeneration++
editor.invalidate()
history.value = []
preview.value = null
picker.value = false
},
)
watch(
() => manifest.value && editorFrames(manifest.value),
(n) => {
if (manifest.value && n !== undefined) manifest.value.spec.render.total_frames = n
},
)
const timer = setInterval(() => {
if (snapshot.value && shouldPoll(snapshot.value.run)) void refresh()
}, 4000)
onBeforeUnmount(() => {
if (typeof window !== 'undefined') window.removeEventListener('beforeunload', beforeUnload)
clearInterval(timer)
refreshGeneration++
forkEpoch++
editor.invalidate()
})
defineExpose({ save, dirty, busy, syncFromServer })
</script>
<template>
<section
class="editable-production surface v2-panel"
:aria-label="manualDialogue ? '逐步骤对白制作' : '可编辑自动成片'"
:tabindex="section === 'shots' || dialogueManifest ? 0 : undefined"
>
<StoryFilmPreview
v-if="section === 'render' || section === 'all'"
:draft-id="draftId"
:refresh-key="history.find((r) => r.state === 'succeeded' && r.output_goal !== 'media')?.id"
:pending="
history.some((r) => r.output_goal !== 'media' && ['queued', 'running'].includes(r.state))
"
/>
<div class="editor-toolbar ui-form-row">
<strong
>{{ manualDialogue ? '逐步骤对白制作' : '可编辑自动成片' }} · v{{
dto?.version || '—'
}}</strong
><span>{{ dirty ? '未保存' : '已保存' }}</span>
<el-button
:disabled="busy || !dto"
@click="save"
>保存编辑</el-button
>
<el-button
v-if="
manifest?.schema_version === 1 &&
manifest.spec.schema_version === 3 &&
capabilities.continuity
"
:disabled="busy"
@click="enableContinuity"
>启用连续性制作</el-button
>
<span v-if="capabilities.continuity && !capabilities.continuity.available">{{
capabilities.continuity.reason
}}</span>
<el-select
v-model="executionMode"
aria-label="自动执行队列"
><el-option
label="交互队列"
value="interactive" /><el-option
label="批量队列"
value="batch"
/></el-select>
<el-button
v-if="!manualDialogue || section === 'render' || section === 'all'"
type="primary"
:disabled="busy || !dto || filmBlocked || dialogueNeedsCertification || !!nativeFilmIssue"
@click="generate('film')"
>{{
manualDialogue ? '合成成片' : history.length ? '生成修改部分并成片' : '自动生成初稿并成片'
}}</el-button
>
<el-button
v-if="!manualDialogue"
:disabled="busy || !dto || dialogueNeedsCertification || !!nativeFilmIssue"
@click="generate('media')"
>仅生成素材</el-button
>
<el-button
:disabled="busy"
@click="refresh"
>刷新进度</el-button
>
</div>
<p
v-if="notice"
role="alert"
class="notice warning"
>
{{ notice }}
</p>
<p v-if="!dto">
{{
notice
? '编辑接口暂不可用,请检查服务端版本或重新读取;已有人工草稿已保留。'
: '正在读取编辑草稿…'
}}
<el-button
:disabled="busy"
@click="editor.load"
>重新读取</el-button
>
</p>
<template v-if="manifest && dto">
<p
v-if="manifest.schema_version === 4 && !capabilities.editorV4 && !capabilities.loading"
class="notice warning"
>
此草稿使用编辑器 V4。当前服务可查看已保存内容,保存修改和新版操作需要支持 V4 的服务。
</p>
<p
v-for="(issue, i) in dto.issues"
:key="i"
class="notice warning"
>
{{ issue.shot_id }} {{ issue.message }}
</p>
<p class="muted">
{{ manifest.shot_ids.length }} 镜头 ·
{{ (total / 24).toFixed(2) }} 秒。生成会先保存,再自动复用有效素材并执行所需阶段。
</p>
<p
v-if="dialogueNeedsCertification || nativeFilmIssue"
class="muted"
>
{{ nativeFilmIssue || dialogueGenerationReason }}
</p>
<p
v-else-if="nativeDialogue && nativeLandscapeOnly(capabilities.forTask('video.generate'))"
class="muted"
>
{{ H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION }}。
</p>
<StoryBaselineBoard
v-if="section === 'baseline' && manifest.source_kind === 'story'"
:spec="manifest.spec"
:identity="`${draftId}:${dto.version}`"
>
<DialogueEditor
:editor-v4="capabilities.editorV4"
v-if="dialogueManifest"
section="baseline"
:manifest="dialogueManifest"
:assets="dto.assets"
:busy="busy"
:native-available="dialogueAvailable"
:native-reason="dialogueGenerationReason"
:languages="capabilities.dialogue?.native_av?.languages"
@pick-reference="pick"
@preview="preview = $event"
:visible-limit="visibleLimit"
/>
</StoryBaselineBoard>
<div
v-if="section === 'shots' || section === 'all'"
class="editor-shot-layout"
>
<aside>
<button
v-for="(id, i) in manifest.shot_ids"
:key="id"
:class="{ active: index === i }"
@click="index = i"
>
{{ i + 1 }} ·
{{ 'name' in manifest.spec.shots[i]! ? manifest.spec.shots[i]!.name : '镜头' }}
</button>
<div class="editor-toolbar editor-shot-actions ui-actions">
<el-button
:disabled="busy"
@click="add"
>+镜头</el-button
><el-button
:disabled="busy || !canMoveEditorShot(manifest, index, index - 1)"
@click="move(-1)"
>上移</el-button
><el-button
:disabled="busy || !canMoveEditorShot(manifest, index, index + 1)"
@click="move(1)"
>下移</el-button
><el-button
:disabled="
busy ||
manifest.shot_ids.length <= 1 ||
(!!dialogueManifest &&
!!dialogueShot &&
!canChangeSequence(dialogueManifest.spec, dialogueShot))
"
@click="remove"
>删除</el-button
>
</div>
</aside>
<div
v-if="shot"
class="editor-shot-body"
>
<StoryShotEditor
v-if="'id' in shot && manifest.source_kind === 'story'"
:spec="manifest.spec"
:shot="shot"
:tp2-available="tp2Available"
:tp2-reason="tp2Reason"
:native-tp2-available="nativeTp2Available"
:native-tp2-reason="nativeTp2Capability?.reason"
:video-capability="capabilities.forTask('video.generate')"
:continuity-available="capabilities.continuity?.available === true"
:manual-video="manifest.bindings[`video:${shotId}`]?.source === 'manual'"
@timing="manifest.spec.render.total_frames = total"
/>
<template v-else-if="'prompt' in shot"
><label
>视频生成模型<select
:value="shot.parameters.profile ?? LEGACY_VIDEO_PROFILE"
@change="shot.parameters.profile = ($event.target as HTMLSelectElement).value"
>
<option :value="H3_VIDEO_PROFILE">MiniMax H3 Base FL2VA</option>
<option :value="LEGACY_VIDEO_PROFILE">Wan2.2(历史兼容)</option>
</select></label
>
<small v-if="shot.parameters.profile === H3_VIDEO_PROFILE"
>H3 最多生成 14 秒静音片段;音轨和字幕保持独立编辑。</small
>
<p
v-if="
shot.parameters.profile === H3_VIDEO_PROFILE && (shot.duration_frames ?? 120) > 336
"
class="notice warning"
>
H3 单镜头最多支持 14 秒;原帧数已保留,请调整时长或选择历史 Wan 模型。
</p>
<label class="ui-field--full"
>镜头提示词<textarea
class="ui-field--full"
v-model="shot.prompt"
rows="4"
/></label
><label
>选用帧数<input
:value="shot.duration_frames ?? 120"
@input="
setEditorShotDuration(
manifest,
index,
Number(($event.target as HTMLInputElement).value),
)
"
type="number"
min="24" /></label
><label
>随机种子<input
v-model.number="shot.parameters.seed"
type="number" /></label
></template>
<DialogueEditor
:editor-v4="capabilities.editorV4"
v-if="dialogueManifest && dialogueShot"
section="shots"
:two-person="capabilities.dialogue?.native_av?.two_person_turns"
:dirty="dirty"
@preview-cuts="previewCutShot = shotId"
:manifest="dialogueManifest"
:shot="dialogueShot"
:assets="dto.assets"
:busy="busy"
:native-available="dialogueAvailable"
:native-reason="dialogueGenerationReason"
:visible-limit="visibleLimit"
@preview="preview = $event"
@target="runDialogueTarget"
/>
<CutForkPreview
v-if="
capabilities.editorV4 &&
previewCutShot === shotId &&
!!shotId &&
dialogueShot?.performance.dialogue_staging === 'two_person_turns'
"
:key="draftId + ':' + dto.version + ':' + shotId"
:draft-id="draftId"
:version="dto.version"
:shot-id="shotId"
:dirty="dirty"
:name="dto.name"
@cancel="previewCutShot = ''"
@forked="emit('forked', $event)"
/>
<section
v-if="
dialogueShot?.performance.dialogue_staging === 'two_person_turns' && history.length
"
aria-label="本镜候选"
>
<label
>查看试拍运行<select
:value="snapshot?.run.id ?? ''"
@change="openRun(($event.target as HTMLSelectElement).value)"
>
<option
value=""
disabled
>
选择运行版本
</option>
<option
v-for="r in history"
:key="r.id"
:value="r.id"
>
r{{ r.draft_revision }} · {{ r.id.slice(-8) }} · {{ r.state }}
</option>
</select></label
>
<template v-if="snapshot"
><TurnReviewPanel
v-for="review in (snapshot.run.turn_reviews ?? []).filter(
(r) => r.shot_id === shotId,
)"
:key="snapshot.run.id + review.shot_id + review.report_sha256"
:run="snapshot.run"
:review="review"
:video="snapshot.run.result_assets.find((a) => a.id === review.video_asset_id)"
@updated="snapshot = $event"
/>
<small v-if="!snapshot.run.turn_reviews?.some((r) => r.shot_id === shotId)"
>此运行尚无本镜已绑定的逐轮报告。</small
>
</template>
</section>
<div
v-for="kind in manifest.schema_version === 2
? ['frame', 'end_frame', 'video']
: dialogueManifest && capabilities.continuity?.available
? ['frame', 'end_frame', 'video']
: ['frame', 'video']"
:key="kind"
class="editor-binding ui-form-row"
>
<strong>{{
kind === 'frame' ? '首帧' : kind === 'end_frame' ? '尾帧' : '视频'
}}</strong>
<small v-if="manifest.bindings[`${kind}:${shotId}`]">{{
{ manual: '人工导入', generated: '模型生成', reused: '复用素材' }[
manifest.bindings[`${kind}:${shotId}`]!.source
]
}}</small>
<small v-if="manifest.bindings[`${kind}:${shotId}`]?.generation_parameters"
>实际生成参数:{{
JSON.stringify(manifest.bindings[`${kind}:${shotId}`]?.generation_parameters)
}}</small
><el-button
v-if="assetFor(`${kind}:${shotId}`)"
@click="preview = assetFor(`${kind}:${shotId}`)!"
>预览当前素材</el-button
><el-button @click="pick(`${kind}:${shotId}`, kind === 'video' ? 'video' : 'image')"
>导入{{ kind === 'video' ? '视频' : '图片' }}</el-button
><el-button
v-if="!dialogueManifest || kind !== 'video'"
:disabled="busy"
@click="generate(dialogueManifest ? 'media' : 'film', [`${kind}:${shotId}`], true)"
>重新生成此{{ kind === 'frame' ? '首帧' : kind === 'end_frame' ? '尾帧' : '视频'
}}{{ dialogueManifest ? '' : '并成片' }}</el-button
><label v-if="manifest.bindings[`${kind}:${shotId}`]"
><input
v-model="manifest.bindings[`${kind}:${shotId}`]!.locked"
type="checkbox"
/>锁定素材</label
>
</div>
<el-button
v-if="assetFor(`join_anchor:${shotId}`)"
@click="preview = assetFor(`join_anchor:${shotId}`)!"
>预览服务端衔接帧</el-button
>
<label
class="ui-field--full editor-segment"
v-for="s in manifest.schema_version === 1 ? selectedSegments : []"
:key="s.id"
>旁白文案<textarea
class="ui-field--full"
v-model="s.text"
maxlength="2000"
rows="2"
/>
<div class="editor-toolbar ui-form-row">
<label
>声音<input
v-model="s.voice"
placeholder="继承全局声音" /></label
><label
>语速<input
:value="s.speed"
@input="setEditorSegmentSpeed(s, ($event.target as HTMLInputElement).value)"
type="number"
step="0.1"
min="0.5"
max="2"
placeholder="继承全局语速" /></label
><el-button
@click="generate('film', [`audio:${s.id}`], true)"
:disabled="busy"
>{{
manifest.audio.mode === 'generated_narration'
? '重配此段并成片'
: '启用旁白并重配此段'
}}</el-button
><el-button @click="pick(`audio:${s.id}`, 'audio')">导入段音频</el-button
><el-button @click="removeEditorSegment(manifest, s.id)">删除段</el-button>
</div></label
>
<el-button
v-if="manifest.schema_version === 1"
@click="manifest.audio.segments.push({ id: editorId(), shot_id: shotId, text: '' })"
>添加旁白段</el-button
>
</div>
</div>
<section
v-if="section === 'render' || section === 'all'"
class="editor-timeline"
aria-label="音轨与字幕时间线"
>
<h3>成片 · 音轨与字幕</h3>
<DialogueEditor
:editor-v4="capabilities.editorV4"
v-if="dialogueManifest"
section="render"
:manifest="dialogueManifest"
:assets="dto.assets"
:busy="busy"
:native-available="dialogueAvailable"
:visible-limit="visibleLimit"
/>
<section
v-if="
nativeDialogue &&
(manifest.audio.segments.length || manifest.audio.track || nativeAudioConflict)
"
class="native-legacy-narration"
>
<p class="muted">
历史独立旁白及成品音轨只读保留。H3原生对白不使用独立配音;画外台词请在镜头对白中编写。
</p>
<p
v-if="!nativeAudioConflict"
class="muted"
>
历史旁白已关闭,原文案、录音与背景音乐仍保留。
</p>
<ul v-if="manifest.audio.segments.length">
<li
v-for="segment in manifest.audio.segments"
:key="segment.id"
>
{{ segment.text }}
<el-button
v-if="assetFor('audio:' + segment.id)"
@click="preview = assetFor('audio:' + segment.id)!"
>试听历史旁白</el-button
>
</li>
</ul>
<el-button
v-if="nativeAudioConflict"
:disabled="busy"
@click="disableLegacyNarration"
>关闭历史独立旁白及成品音轨</el-button
>
</section>
<div
v-if="manifest.schema_version !== 1"
class="continuity-mix"
style="max-height: 55vh; overflow: auto"
>
<el-button
v-for="role in ['bgm', 'sfx'] as const"
:key="role"
:disabled="(manifest.audio.layers?.length ?? 0) >= 32"
@click="pick(role, 'audio')"
>{{ role === 'bgm' ? '添加背景音乐' : '添加音效' }}</el-button
>
<el-button
v-if="!nativeDialogue"
@click="manifest.audio.segments.push({ id: editorId(), text: '', anchor: 'absolute' })"
>添加跨镜头旁白</el-button
>
<label
>{{ dialogueManifest ? '对白及旁白期间降低背景音乐音量' : '旁白期间降低背景音乐音量'
}}<input
type="checkbox"
v-model="manifest.audio.ducking"
/></label>
<div
v-for="part in [
...(nativeDialogue ? [] : manifest.audio.segments),
...(manifest.audio.layers ?? []),
]"
:key="part.id"
class="ui-form-grid"
>
<label
v-if="'text' in part"
class="ui-field--full"
>旁白<el-input
type="textarea"
:rows="2"
v-model="part.text" /></label
><span v-else>{{ part.role }} · {{ part.asset_id }}</span>
<label
>定位<select
:value="part.anchor ?? 'shot'"
@change="setAnchor(part, ($event.target as HTMLSelectElement).value)"
>
<option value="shot">镜头</option>
<option
v-if="'scenes' in manifest.spec && manifest.spec.scenes.length"
value="scene"
>
场景
</option>
<option value="absolute">全片</option>
</select></label
>
<select
v-if="(part.anchor ?? 'shot') === 'shot'"
v-model="part.shot_id"
>
<option
v-for="(id, i) in manifest.shot_ids"
:key="id"
:value="id"
>
{{ i + 1 }}
</option>
</select>
<select
v-if="part.anchor === 'scene' && 'scenes' in manifest.spec"
v-model="part.scene_id"
>
<option
v-for="scene in manifest.spec.scenes"
:key="scene.id"
:value="scene.id"
>
{{ scene.name }}
</option>
</select>
<label
v-for="field in audioFields"
:key="field[0]"
>{{ field[1]
}}<input
type="number"
:placeholder="field[0] === 'source_end_sample' ? '完整音频' : undefined"
:step="field[0] === 'gain_db' ? 0.1 : 'any'"
:value="field[0] === 'gain_db' ? part[field[0]] : samplesToSeconds(part[field[0]])"
@change="setSample(part, field[0], ($event.target as HTMLInputElement).value)"
/></label>
<el-button
v-if="'role' in part"
@click="
manifest.audio.layers = manifest.audio.layers?.filter((l) => l.id !== part.id)
"
>移除音层</el-button
>
<template v-else
><el-button @click="generate('film', [`audio:${part.id}`], true)"
>重做此段配音</el-button
><el-button @click="removeEditorSegment(manifest, part.id)"
>移除旁白</el-button
></template
>
</div>
<el-button
v-if="nativeDialogue"
:disabled="remixBlocked"
@click="generate(remixGoal)"
>重新混音并成片</el-button
>
<p>贡献帧共 {{ total }} 帧 · 混音最多 128 段,音乐和音效最多 32 层</p>
<ol>
<li
v-for="(s, i) in manifest.spec.shots"
:key="manifest.shot_ids[i]"
>
镜头 {{ i + 1 }} ·
{{
'edit' in s
? s.edit.duration_frames - (s.edit.dedup_frames ?? 0)
: s.duration_frames
}}
帧
</li>
</ol>
</div>
<div class="editor-toolbar ui-form-row">
<label
>画幅<select v-model="manifest.spec.profile">
<option value="landscape_1080_v1">横屏</option>
<option value="portrait_1080_v1">竖屏</option>
</select></label
><label
>适配<select v-model="manifest.spec.render.fit">
<option value="contain">完整显示</option>
<option value="cover">填充</option>
</select></label
>
</div>
<ol
v-if="manifest.schema_version === 1"
class="editor-timeline-shots"
>
<li
v-for="(id, i) in manifest.shot_ids"
:key="id"
@click="index = i"
>
镜头 {{ i + 1 }} ·
{{
'edit' in manifest.spec.shots[i]!
? manifest.spec.shots[i]!.edit.duration_frames
: (manifest.spec.shots[i]!.duration_frames ?? 120)
}}
帧
</li>
</ol>
<div class="editor-toolbar ui-form-row">
<label v-if="dialogueManifest && !nativeDialogue"
>混音模式<select
:value="dialogueManifest.audio.mix_mode"
@change="setMixMode(($event.target as HTMLSelectElement).value)"
>
<option value="composed">对白自动混音</option>
<option value="manual_mix">人工成品音轨</option>
</select>
</label>
<label v-if="dialogueManifest">
<input
type="checkbox"
v-model="dialogueManifest.spec.dialogue.enabled"
/>本次成片使用对白
</label>
<label v-if="!nativeDialogue"
>{{ dialogueManifest ? '旁白 / 音轨' : '声音模式'
}}<select v-model="manifest.audio.mode">
<option value="silent">{{ dialogueManifest ? '无旁白' : '静音' }}</option>
<option
v-if="
!nativeDialogue &&
(!dialogueManifest || dialogueManifest.audio.mix_mode === 'manual_mix')
"
value="manual_track"
>
人工音轨
</option>
<option value="generated_narration">生成旁白</option>
</select></label
><label v-if="!nativeDialogue">全局声音<input v-model="manifest.audio.voice" /></label
><label v-if="!nativeDialogue"
>全局语速<input
v-model.number="manifest.audio.speed"
type="number"
step="0.1"
min="0.5"
max="2" /></label
><el-button
v-if="
!nativeDialogue &&
(!dialogueManifest || dialogueManifest.audio.mix_mode === 'manual_mix')
"
@click="pick('track', 'audio')"
>选择音轨</el-button
><el-button
v-if="!nativeDialogue"
@click="generate('film', ['script'], true)"
:disabled="busy"
>{{
manifest.audio.mode === 'generated_narration'
? '生成缺少的旁白文案并成片'
: '启用旁白并生成缺少的文案'
}}</el-button
>
</div>
<p
v-if="filmBlocked"
class="notice warning"
>
{{
nativeDialogue
? '请关闭历史独立旁白及成品音轨后再成片,背景音乐和音效可继续使用。'
: '请切回对白自动混音,或取消选中「本次成片使用对白」以采用人工成品音轨。'
}}
</p>
<div
v-if="!nativeDialogue && manifest.audio.mode === 'manual_track' && manifest.audio.track"
class="editor-toolbar ui-form-row"
>
<template v-if="'sample_rate' in manifest.audio.track">
<label
>音源起点(秒)<input
type="number"
step="any"
:value="samplesToSeconds(manifest.audio.track.source_start_sample)"
@change="
manifest.audio.track.source_start_sample = secondsToSamples(
Number(($event.target as HTMLInputElement).value),
)
"
/></label>
<label
>音源终点(秒)<input
type="number"
step="any"
:value="samplesToSeconds(manifest.audio.track.source_end_sample)"
@change="
manifest.audio.track.source_end_sample = secondsToSamples(
Number(($event.target as HTMLInputElement).value),
)
"
/></label>
<label
>成片起点(秒)<input
type="number"
step="any"
:value="samplesToSeconds(manifest.audio.track.offset_sample)"
@change="
manifest.audio.track.offset_sample = secondsToSamples(
Number(($event.target as HTMLInputElement).value),
)
"
/></label> </template
><template v-else
><label
>音源开始 ms<input
v-model.number="manifest.audio.track.source_start_ms"
type="number" /></label
><label
>音源结束 ms<input
v-model.number="manifest.audio.track.source_end_ms"
type="number" /></label
><label
>起点帧<input
v-model.number="manifest.audio.track.offset_frame"
type="number" /></label
></template>
</div>
<div class="editor-toolbar ui-form-row">
<label
>字幕模式<select v-model="manifest.captions.mode">
<option value="none">关闭字幕</option>
<option value="manual">人工字幕</option>
<option value="script">
{{ nativeDialogue ? '对白文案' : dialogueManifest ? '对白和旁白文案' : '旁白文案' }}
</option>
<option
v-if="!nativeDialogue"
value="ai_script"
>
AI补齐文案
</option>
<option
v-else-if="manifest.captions.mode === 'ai_script'"
value="ai_script"
disabled
>
历史AI文案(请选择对白文案)
</option>
</select></label
><el-button @click="addCue">添加字幕</el-button
><el-button
:disabled="busy || manifest.captions.mode === 'none'"
@click="
capabilities.editorV4 && nativeDialogue
? generate('caption_film')
: generate('film', ['captions'], true)
"
>更新字幕并成片</el-button
>
</div>
<RhythmCaptions
v-if="
capabilities.editorV4 &&
nativeDialogue &&
dialogueManifest &&
manifest.captions.mode === 'script'
"
:draft-id="draftId"
:version="dto.version"
:manifest="dialogueManifest"
:assets="dto.assets"
:busy="busy"
@apply="save"
@inspect="generate('caption_inspect', ['native_report:' + $event])"
/>
<p
v-if="manifest.captions.mode === 'none'"
class="muted"
>
字幕已关闭;请启用字幕模式后更新。
</p>
<p class="muted">
镜头、旁白段{{ dialogueManifest ? '与台词' : '' }}锚点使用相对帧,全片锚点使用绝对帧。
</p>
<div
v-if="manifest.captions.cues.length"
class="editor-cues-scroll editor-scroll-region"
role="region"
aria-label="字幕文案与锚点"
tabindex="0"
>
<article
v-for="c in manifest.captions.cues"
:key="c.id"
class="editor-cue"
>
<label class="ui-field--full"
>字幕文案<textarea
class="ui-field--full"
v-model="c.text"
@input="c.text_override = true"
/>
</label>
<div class="editor-toolbar ui-form-row">
<label
>锚点<select
v-model="c.anchor"
@change="anchor(c)"
>
<option value="absolute">全片</option>
<option value="shot">镜头</option>
<option value="audio_segment">旁白段</option>
<option
v-if="dialogueManifest?.spec.dialogue.utterances.length"
value="utterance"
>
台词
</option>
</select></label
><label v-if="c.anchor === 'shot'"
>镜头<select
v-model="c.shot_id"
aria-label="字幕镜头"
>
<option
v-for="(id, i) in manifest.shot_ids"
:key="id"
:value="id"
>
镜头 {{ i + 1 }}
</option>
</select></label
><label v-if="c.anchor === 'audio_segment'"
>旁白段<select
v-model="c.segment_id"
aria-label="字幕旁白段"
>
<option
v-for="s in manifest.audio.segments"
:key="s.id"
:value="s.id"
>
{{ s.text || s.id }}
</option>
</select></label
><label v-if="c.anchor === 'utterance' && dialogueManifest"
>台词<select v-model="c.utterance_id">
<option
v-for="line in dialogueManifest.spec.dialogue.utterances"
:key="line.id"
:value="line.id"
>
{{ line.text }}
</option>
</select> </label
><label class="editor-cue-frame-field"
>开始帧<input
v-model.number="c.start_frame"
type="number"
@input="c.timing_override = true" /></label
><label class="editor-cue-frame-field"
>结束帧<input
v-model.number="c.end_frame"
type="number"
@input="c.timing_override = true"
/></label>
<div class="editor-cue-options ui-actions">
<label
><input
v-model="c.text_override"
type="checkbox"
/>保护人工文案</label
><label
><input
v-model="c.timing_override"
type="checkbox"
/>保护人工时间</label
><el-button
@click="
manifest.captions.cues = manifest.captions.cues.filter((row) => row.id !== c.id)
"
>删除字幕</el-button
>
</div>
</div>
</article>
</div>
<p
v-else
class="muted"
>
暂无字幕,点击“添加字幕”创建。
</p>
</section>
<template v-if="section === 'render' || section === 'all'">
<details v-if="plan">
<summary>最近执行计划 · {{ plan.steps.length }} 阶段</summary>
<div
class="editor-run-details-scroll editor-scroll-region"
role="region"
aria-label="最近执行计划明细"
tabindex="0"
>
<p
v-for="s in plan.steps"
:key="s.key"
>
{{ s.key }} ·
{{
{
reuse: '复用',
generate: '生成',
pending_dependency: '等待前序步骤',
analyze: '分析',
manual: '需人工处理',
}[s.status] || s.status
}}<span v-if="s.reason"> · {{ s.reason }}</span>
</p>
</div>
</details>
<section
v-if="snapshot"
class="editor-run-scroll editor-scroll-region"
role="region"
aria-label="成片工作流"
tabindex="0"
>
<RunCard
:snapshot="snapshot"
@updated="snapshot = $event"
/>
</section>
<div
v-if="snapshot && canForkPrepared(snapshot.run)"
class="ui-actions"
>
<router-link
v-if="preparedForks[snapshot.run.id]"
:to="`/studio/${encodeURIComponent(preparedForks[snapshot.run.id]!)}`"
>打开准备稿</router-link
>
<el-button
v-else
:disabled="busy || dirty"
@click="forkPrepared(snapshot.run)"
>
准备结构另存故事
</el-button>
</div>
<details>
<summary>版本与运行历史({{ history.length }})</summary>
<div
v-if="history.length"
class="editor-run-details-scroll editor-scroll-region"
role="region"
aria-label="版本与运行历史"
tabindex="0"
>
<article
v-for="r in history"
:key="r.id"
class="editor-history ui-actions"
>
<span
>{{ r.output_goal === 'media' ? '素材' : '成片' }} · {{ r.id.slice(-8) }} ·
{{ r.state }} · r{{ r.draft_revision }}</span
><a
v-if="r.state === 'succeeded' && r.captions_srt_available"
:href="captionSrtUrl(draftId, r.id)"
download
>下载该版本 SRT</a
><el-button
:disabled="busy || dirty"
@click="restore(r.id)"
>从此版本恢复编辑</el-button
><el-button
v-if="r.state === 'succeeded'"
:disabled="busy || dirty"
@click="restore(r.id, true)"
>应用此运行成果</el-button
><el-button
v-if="canForkPrepared(r) && r.id !== snapshot?.run.id && !preparedForks[r.id]"
:disabled="busy || dirty"
@click="forkPrepared(r)"
>准备结构另存故事</el-button
><router-link
v-if="canForkPrepared(r) && r.id !== snapshot?.run.id && preparedForks[r.id]"
:to="`/studio/${encodeURIComponent(preparedForks[r.id]!)}`"
>打开准备稿</router-link
><el-button
:disabled="busy"
@click="openRun(r.id)"
>查看运行进度与成果</el-button
><span v-if="dirty">请先保存当前修改</span>
</article>
</div>
<el-button
v-if="history.length < historyTotal"
:loading="historyLoading"
@click="loadMoreHistory"
>加载更早版本({{ history.length }} / {{ historyTotal }})</el-button
>
</details>
</template>
</template>
<AssetPicker
v-model="picker"
:kinds="pickerKinds"
@select="selected"
/><AssetPreview v-model:asset="preview" />
</section>
</template>
<style scoped>
.editable-production {
min-width: 0;
}
.editor-scroll-region {
min-width: 0;
min-height: 0;
overflow: auto;
overscroll-behavior: contain;
scrollbar-gutter: stable;
scrollbar-width: thin;
scrollbar-color: transparent transparent;
}
.editor-scroll-region:is(:hover, :focus-visible) {
scrollbar-color: #607885 transparent;
}
.editor-scroll-region::-webkit-scrollbar-thumb {
background: transparent;
}
.editor-scroll-region:is(:hover, :focus-visible)::-webkit-scrollbar-thumb {
background: #607885;
}
.editor-scroll-region:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.editor-run-scroll {
height: 420px;
max-height: 60vh;
}
.editor-run-scroll > :deep(.v2-panel) {
margin-bottom: 0;
}
.editor-cues-scroll {
height: 480px;
max-height: 65vh;
border: 1px solid var(--line);
border-radius: 10px;
padding-inline: 8px;
}
.editor-cues-scroll > .editor-cue:first-child {
border-top: 0;
}
.editor-cue-frame-field {
/* 短帧号字段缩短宽度,让桌面端的保护选项和删除操作留在同一行。 */
--ui-control-width: 160px;
}
.editor-run-details-scroll {
max-height: 280px;
}
@media (hover: none) {
.editor-scroll-region {
scrollbar-color: #607885 transparent;
}
.editor-scroll-region::-webkit-scrollbar-thumb {
background: #607885;
}
}
.editor-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
column-gap: var(--ui-control-gap);
row-gap: var(--ui-form-row-gap);
margin: var(--ui-form-row-gap) 0;
}
.editor-shot-layout {
display: grid;
grid-template-columns: 180px minmax(0, 1fr);
gap: 16px;
}
.editor-shot-layout > aside > button {
display: block;
width: 100%;
padding: 10px;
text-align: left;
border: 1px solid var(--line);
background: transparent;
color: inherit;
border-radius: 8px;
margin: 4px 0;
}
.editor-shot-layout .active {
background: color-mix(in srgb, var(--accent) 14%, var(--panel));
color: var(--el-text-color-primary);
}
.editor-shot-body {
min-width: 0;
display: grid;
gap: var(--ui-form-row-gap);
}
.editor-shot-body :deep(.story-shot-editor) {
width: auto;
min-width: 0;
/* 此处由整个编辑面板滚动,避免旧三列布局的高度和列号影响嵌入表单。 */
grid-column: auto;
max-height: none;
overflow: visible;
}
label {
display: flex;
flex-direction: column;
gap: var(--ui-label-gap);
font-size: 13px;
}
label:has(input[type='checkbox']) {
width: auto;
flex: 0 0 auto;
flex-direction: row;
align-items: center;
}
input:not([type='checkbox']),
textarea,
select {
box-sizing: border-box;
max-width: 100%;
border: 1px solid var(--line);
border-radius: 6px;
padding: 7px;
background: var(--panel);
color: inherit;
}
textarea {
width: 100%;
resize: vertical;
}
.editor-cue,
.editor-binding,
.editor-history {
padding: 10px 0;
border-top: 1px solid var(--line);
}
.editor-timeline-shots {
display: flex;
list-style: none;
overflow: auto;
padding: 0;
gap: 8px;
}
.editor-timeline-shots li {
flex: 0 0 auto;
background: var(--panel);
padding: 10px;
color: var(--el-text-color-primary);
}
.editor-history {
display: flex;
flex-wrap: wrap;
column-gap: var(--ui-control-gap);
row-gap: var(--ui-form-row-gap);
align-items: center;
}
@media (max-width: 680px) {
.editor-shot-layout {
grid-template-columns: minmax(0, 1fr);
}
.editor-shot-layout > aside {
display: flex;
overflow: auto;
gap: 6px;
flex-wrap: wrap;
}
.editor-shot-layout > aside > button {
width: auto;
}
.editor-toolbar {
align-items: stretch;
}
.editor-toolbar > label {
max-width: 100%;
}
}
.editor-shot-body > label,
.editor-cue > label {
margin: 0;
}
.editor-shot-body .editor-toolbar,
.editor-timeline .editor-toolbar {
margin: 0;
}
.editor-timeline {
display: grid;
align-content: start;
gap: var(--ui-form-row-gap);
}
.editor-timeline > :is(h3, p, ol) {
margin: 0;
}
.editor-cue {
display: grid;
gap: var(--ui-form-row-gap);
}
.editor-shot-actions.ui-actions {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--ui-control-gap);
width: 100%;
margin: var(--ui-form-row-gap) 0;
}
.editor-shot-actions.ui-actions > .el-button {
width: 100%;
min-width: 0;
height: var(--ui-control-height);
margin: 0;
padding-inline: 8px;
}
@media (max-width: 680px) {
.editor-shot-layout > aside > .editor-shot-actions {
flex: 1 0 100%;
}
}
</style>