926 lines
28 KiB
Vue
926 lines
28 KiB
Vue
|
|
<script setup lang="ts">
|
|||
|
|
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|||
|
|
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,
|
|||
|
|
} from '../domain/creation/editor'
|
|||
|
|
import { createShot } from '../domain/stories/rules'
|
|||
|
|
import { createWorkflowShot } from '../domain/workflows/timeline'
|
|||
|
|
import type { EditorDTO, EditorCue } 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 StoryShotEditor from './studio/StoryShotEditor.vue'
|
|||
|
|
const props = withDefaults(
|
|||
|
|
defineProps<{
|
|||
|
|
draftId: string
|
|||
|
|
draftName?: string
|
|||
|
|
outputFolderId?: string | null
|
|||
|
|
section?: 'baseline' | 'shots' | 'render' | 'all'
|
|||
|
|
}>(),
|
|||
|
|
{ section: 'all' },
|
|||
|
|
)
|
|||
|
|
const emit = defineEmits<{
|
|||
|
|
dirty: [value: boolean]
|
|||
|
|
saved: [value: EditorDTO, submittedName?: string]
|
|||
|
|
loaded: [value: EditorDTO]
|
|||
|
|
}>()
|
|||
|
|
const editor = useEditableProduction(
|
|||
|
|
() => props.draftId,
|
|||
|
|
() => props.outputFolderId,
|
|||
|
|
() => props.draftName,
|
|||
|
|
)
|
|||
|
|
const { dto, manifest, busy, notice, dirty, plan, snapshot, executionMode } = editor
|
|||
|
|
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'])
|
|||
|
|
const shot = computed(() => manifest.value?.spec.shots[index.value]),
|
|||
|
|
shotId = computed(() => manifest.value?.shot_ids[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) || [],
|
|||
|
|
)
|
|||
|
|
const film = computed(() =>
|
|||
|
|
history.value
|
|||
|
|
.find(
|
|||
|
|
(r) =>
|
|||
|
|
r.state === 'succeeded' &&
|
|||
|
|
r.output_goal !== 'media' &&
|
|||
|
|
r.result_assets.some((a) => a.kind === 'video'),
|
|||
|
|
)
|
|||
|
|
?.result_assets.find((a) => a.kind === 'video'),
|
|||
|
|
)
|
|||
|
|
let refreshToken = 0,
|
|||
|
|
historyToken = 0
|
|||
|
|
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))
|
|||
|
|
}
|
|||
|
|
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 api.runs({ draft_id: id, page, page_size: 100 })
|
|||
|
|
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
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
async function refresh() {
|
|||
|
|
const acceptEditor = editor.refreshGuard()
|
|||
|
|
const token = ++refreshToken,
|
|||
|
|
id = props.draftId,
|
|||
|
|
session = getSessionGeneration()
|
|||
|
|
try {
|
|||
|
|
const result = await api.runs({ draft_id: id, page_size: 100 })
|
|||
|
|
if (token !== refreshToken || id !== props.draftId || session !== getSessionGeneration()) return
|
|||
|
|
if (historyPage.value === 1) history.value = result.items
|
|||
|
|
else mergeHistory(result.items)
|
|||
|
|
historyTotal.value = result.total
|
|||
|
|
const activeId =
|
|||
|
|
snapshot.value?.run.id ||
|
|||
|
|
history.value.find(
|
|||
|
|
(r) => !['succeeded', 'failed', 'cancelled', 'timed_out'].includes(r.state),
|
|||
|
|
)?.id
|
|||
|
|
if (activeId) {
|
|||
|
|
const current = await api.run(activeId)
|
|||
|
|
if (token !== refreshToken || session !== getSessionGeneration() || id !== props.draftId)
|
|||
|
|
return
|
|||
|
|
snapshot.value = current
|
|||
|
|
if (current.run.apply_state === 'applied' && !dirty.value) {
|
|||
|
|
const sent = JSON.stringify(manifest.value),
|
|||
|
|
value = await api.editor(id)
|
|||
|
|
if (
|
|||
|
|
token === refreshToken &&
|
|||
|
|
session === getSessionGeneration() &&
|
|||
|
|
id === props.draftId &&
|
|||
|
|
sent === JSON.stringify(manifest.value)
|
|||
|
|
) {
|
|||
|
|
if (acceptEditor(value)) emit('saved', value)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} catch (e) {
|
|||
|
|
if (token === refreshToken && session === getSessionGeneration()) notice.value = errorMessage(e)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
async function openRun(id: string) {
|
|||
|
|
const token = ++refreshToken,
|
|||
|
|
session = getSessionGeneration(),
|
|||
|
|
draftId = props.draftId
|
|||
|
|
try {
|
|||
|
|
const value = await api.run(id)
|
|||
|
|
if (token === refreshToken && session === getSessionGeneration() && draftId === props.draftId)
|
|||
|
|
snapshot.value = value
|
|||
|
|
} catch (e) {
|
|||
|
|
if (token === refreshToken && session === getSessionGeneration()) 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
|
|||
|
|
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: 'media' | 'film', targets: string[] = [], force = false) {
|
|||
|
|
if (!manifest.value || busy.value) return
|
|||
|
|
if (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()
|
|||
|
|
}
|
|||
|
|
async function restore(id: string, apply = false) {
|
|||
|
|
await editor.restore(id, apply)
|
|||
|
|
if (dto.value) emit('saved', dto.value)
|
|||
|
|
}
|
|||
|
|
function add() {
|
|||
|
|
if (!manifest.value) return
|
|||
|
|
const m = manifest.value
|
|||
|
|
const s = m.source_kind === 'story' ? createShot() : createWorkflowShot(m.spec.shots.length)
|
|||
|
|
const id = 'id' in s ? s.id : editorId()
|
|||
|
|
addEditorShot(m, s, id)
|
|||
|
|
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
|
|||
|
|
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
|
|||
|
|
moveEditorShot(manifest.value, index.value, next)
|
|||
|
|
index.value = next
|
|||
|
|
}
|
|||
|
|
function pick(key: string, kind: AssetKind) {
|
|||
|
|
pickerKey.value = key
|
|||
|
|
pickerKinds.value = [kind]
|
|||
|
|
picker.value = true
|
|||
|
|
}
|
|||
|
|
function selected(asset: Asset) {
|
|||
|
|
const m = manifest.value
|
|||
|
|
if (!m) return
|
|||
|
|
if (pickerKey.value === 'track') {
|
|||
|
|
m.audio.track = {
|
|||
|
|
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'
|
|||
|
|
} 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
|
|||
|
|
if (c.anchor === 'shot') c.shot_id = shotId.value
|
|||
|
|
if (c.anchor === 'audio_segment') c.segment_id = manifest.value?.audio.segments[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 () => {
|
|||
|
|
historyToken++
|
|||
|
|
historyPage.value = 1
|
|||
|
|
historyTotal.value = 0
|
|||
|
|
historyLoading.value = false
|
|||
|
|
history.value = []
|
|||
|
|
index.value = 0
|
|||
|
|
await editor.load()
|
|||
|
|
if (dto.value) emit('loaded', dto.value)
|
|||
|
|
await refresh()
|
|||
|
|
},
|
|||
|
|
{ immediate: true },
|
|||
|
|
)
|
|||
|
|
watch(
|
|||
|
|
() => auth.user,
|
|||
|
|
() => {
|
|||
|
|
refreshToken++
|
|||
|
|
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 &&
|
|||
|
|
!['succeeded', 'failed', 'cancelled', 'timed_out'].includes(snapshot.value.run.state)
|
|||
|
|
)
|
|||
|
|
void refresh()
|
|||
|
|
}, 4000)
|
|||
|
|
onBeforeUnmount(() => {
|
|||
|
|
if (typeof window !== 'undefined') window.removeEventListener('beforeunload', beforeUnload)
|
|||
|
|
clearInterval(timer)
|
|||
|
|
refreshToken++
|
|||
|
|
editor.invalidate()
|
|||
|
|
})
|
|||
|
|
defineExpose({ save, dirty, busy, syncFromServer })
|
|||
|
|
</script>
|
|||
|
|
<template>
|
|||
|
|
<section
|
|||
|
|
class="editable-production surface v2-panel"
|
|||
|
|
aria-label="可编辑自动成片"
|
|||
|
|
:tabindex="section === 'shots' ? 0 : undefined"
|
|||
|
|
>
|
|||
|
|
<div class="editor-toolbar ui-form-row">
|
|||
|
|
<strong>可编辑自动成片 · v{{ dto?.version || '—' }}</strong
|
|||
|
|
><span>{{ dirty ? '未保存' : '已保存' }}</span>
|
|||
|
|
<el-button
|
|||
|
|
:disabled="busy || !dto"
|
|||
|
|
@click="save"
|
|||
|
|
>保存编辑</el-button
|
|||
|
|
>
|
|||
|
|
<el-select
|
|||
|
|
v-model="executionMode"
|
|||
|
|
aria-label="自动执行队列"
|
|||
|
|
><el-option
|
|||
|
|
label="交互队列"
|
|||
|
|
value="interactive" /><el-option
|
|||
|
|
label="批量队列"
|
|||
|
|
value="batch"
|
|||
|
|
/></el-select>
|
|||
|
|
<el-button
|
|||
|
|
type="primary"
|
|||
|
|
:disabled="busy || !dto"
|
|||
|
|
@click="generate('film')"
|
|||
|
|
>{{ history.length ? '生成修改部分并成片' : '自动生成初稿并成片' }}</el-button
|
|||
|
|
>
|
|||
|
|
<el-button
|
|||
|
|
:disabled="busy || !dto"
|
|||
|
|
@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-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>
|
|||
|
|
<StoryBaselineBoard
|
|||
|
|
v-if="
|
|||
|
|
section === 'baseline' &&
|
|||
|
|
manifest.source_kind === 'story' &&
|
|||
|
|
manifest.spec.schema_version === 3
|
|||
|
|
"
|
|||
|
|
:spec="manifest.spec"
|
|||
|
|
:identity="`${draftId}:${dto.version}`"
|
|||
|
|
/>
|
|||
|
|
<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 @click="add">+镜头</el-button><el-button @click="move(-1)">上移</el-button
|
|||
|
|
><el-button @click="move(1)">下移</el-button
|
|||
|
|
><el-button
|
|||
|
|
:disabled="manifest.shot_ids.length <= 1"
|
|||
|
|
@click="remove"
|
|||
|
|
>删除</el-button
|
|||
|
|
>
|
|||
|
|
</div>
|
|||
|
|
</aside>
|
|||
|
|
<div
|
|||
|
|
v-if="shot"
|
|||
|
|
class="editor-shot-body"
|
|||
|
|
>
|
|||
|
|
<StoryShotEditor
|
|||
|
|
v-if="'id' in shot && manifest.spec.schema_version === 3"
|
|||
|
|
:spec="manifest.spec"
|
|||
|
|
:shot="shot"
|
|||
|
|
@timing="manifest.spec.render.total_frames = total"
|
|||
|
|
/>
|
|||
|
|
<template v-else-if="'prompt' in shot"
|
|||
|
|
><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>
|
|||
|
|
<div
|
|||
|
|
v-for="kind in ['frame', 'video'] as const"
|
|||
|
|
:key="kind"
|
|||
|
|
class="editor-binding ui-form-row"
|
|||
|
|
>
|
|||
|
|
<strong>{{ kind === 'frame' ? '首帧' : '视频' }}</strong>
|
|||
|
|
<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 === 'frame' ? 'image' : 'video')"
|
|||
|
|
>导入{{ kind === 'frame' ? '图片' : '视频' }}</el-button
|
|||
|
|
><el-button
|
|||
|
|
:disabled="busy"
|
|||
|
|
@click="generate('film', [`${kind}:${shotId}`], true)"
|
|||
|
|
>重新生成此{{ kind === 'frame' ? '首帧' : '视频' }}并成片</el-button
|
|||
|
|
><label v-if="manifest.bindings[`${kind}:${shotId}`]"
|
|||
|
|
><input
|
|||
|
|
v-model="manifest.bindings[`${kind}:${shotId}`]!.locked"
|
|||
|
|
type="checkbox"
|
|||
|
|
/>锁定素材</label
|
|||
|
|
>
|
|||
|
|
</div>
|
|||
|
|
<label
|
|||
|
|
class="ui-field--full editor-segment"
|
|||
|
|
v-for="s in 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
|
|||
|
|
@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>
|
|||
|
|
<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>
|
|||
|
|
<el-button
|
|||
|
|
v-if="film"
|
|||
|
|
@click="preview = film"
|
|||
|
|
>播放最新完成成片</el-button
|
|||
|
|
>
|
|||
|
|
<p
|
|||
|
|
v-else
|
|||
|
|
class="muted"
|
|||
|
|
>
|
|||
|
|
暂无完成成片;素材任务不会替换成片预览。
|
|||
|
|
</p>
|
|||
|
|
<ol 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
|
|||
|
|
>声音模式<select v-model="manifest.audio.mode">
|
|||
|
|
<option value="silent">静音</option>
|
|||
|
|
<option value="manual_track">人工音轨</option>
|
|||
|
|
<option value="generated_narration">生成旁白</option>
|
|||
|
|
</select></label
|
|||
|
|
><label>全局声音<input v-model="manifest.audio.voice" /></label
|
|||
|
|
><label
|
|||
|
|
>全局语速<input
|
|||
|
|
v-model.number="manifest.audio.speed"
|
|||
|
|
type="number"
|
|||
|
|
step="0.1"
|
|||
|
|
min="0.5"
|
|||
|
|
max="2" /></label
|
|||
|
|
><el-button @click="pick('track', 'audio')">选择音轨</el-button
|
|||
|
|
><el-button
|
|||
|
|
@click="generate('film', ['script'], true)"
|
|||
|
|
:disabled="busy"
|
|||
|
|
>{{
|
|||
|
|
manifest.audio.mode === 'generated_narration'
|
|||
|
|
? '生成缺少的旁白文案并成片'
|
|||
|
|
: '启用旁白并生成缺少的文案'
|
|||
|
|
}}</el-button
|
|||
|
|
>
|
|||
|
|
</div>
|
|||
|
|
<div
|
|||
|
|
v-if="manifest.audio.mode === 'manual_track' && manifest.audio.track"
|
|||
|
|
class="editor-toolbar ui-form-row"
|
|||
|
|
>
|
|||
|
|
<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>
|
|||
|
|
</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">旁白文案</option>
|
|||
|
|
<option value="ai_script">AI补齐文案</option>
|
|||
|
|
</select></label
|
|||
|
|
><el-button @click="addCue">添加字幕</el-button
|
|||
|
|
><el-button
|
|||
|
|
:disabled="busy || manifest.captions.mode === 'none'"
|
|||
|
|
@click="generate('film', ['captions'], true)"
|
|||
|
|
>更新字幕并成片</el-button
|
|||
|
|
>
|
|||
|
|
</div>
|
|||
|
|
<p
|
|||
|
|
v-if="manifest.captions.mode === 'none'"
|
|||
|
|
class="muted"
|
|||
|
|
>
|
|||
|
|
字幕已关闭;请启用字幕模式后更新。
|
|||
|
|
</p>
|
|||
|
|
<p class="muted">镜头与旁白段锚点使用相对帧,全片锚点使用绝对帧。</p>
|
|||
|
|
<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>
|
|||
|
|
</select></label
|
|||
|
|
><select
|
|||
|
|
v-if="c.anchor === 'shot'"
|
|||
|
|
v-model="c.shot_id"
|
|||
|
|
aria-label="字幕镜头"
|
|||
|
|
>
|
|||
|
|
<option
|
|||
|
|
v-for="(id, i) in manifest.shot_ids"
|
|||
|
|
:key="id"
|
|||
|
|
:value="id"
|
|||
|
|
>
|
|||
|
|
镜头 {{ i + 1 }}
|
|||
|
|
</option></select
|
|||
|
|
><select
|
|||
|
|
v-if="c.anchor === 'audio_segment'"
|
|||
|
|
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
|
|||
|
|
>开始帧<input
|
|||
|
|
v-model.number="c.start_frame"
|
|||
|
|
type="number"
|
|||
|
|
@input="c.timing_override = true" /></label
|
|||
|
|
><label
|
|||
|
|
>结束帧<input
|
|||
|
|
v-model.number="c.end_frame"
|
|||
|
|
type="number"
|
|||
|
|
@input="c.timing_override = true" /></label
|
|||
|
|
><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>
|
|||
|
|
</article>
|
|||
|
|
</section>
|
|||
|
|
<details v-if="plan">
|
|||
|
|
<summary>最近执行计划 · {{ plan.steps.length }} 阶段</summary>
|
|||
|
|
<p
|
|||
|
|
v-for="s in plan.steps"
|
|||
|
|
:key="s.key"
|
|||
|
|
>
|
|||
|
|
{{ s.key }} · {{ s.status }}
|
|||
|
|
</p>
|
|||
|
|
</details>
|
|||
|
|
<RunCard
|
|||
|
|
v-if="snapshot"
|
|||
|
|
:snapshot="snapshot"
|
|||
|
|
@updated="snapshot = $event"
|
|||
|
|
/>
|
|||
|
|
<details>
|
|||
|
|
<summary>版本与运行历史({{ history.length }})</summary>
|
|||
|
|
<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
|
|||
|
|
><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
|
|||
|
|
:disabled="busy"
|
|||
|
|
@click="openRun(r.id)"
|
|||
|
|
>查看运行进度与成果</el-button
|
|||
|
|
><span v-if="dirty">请先保存当前修改</span>
|
|||
|
|
</article>
|
|||
|
|
<el-button
|
|||
|
|
v-if="history.length < historyTotal"
|
|||
|
|
:loading="historyLoading"
|
|||
|
|
@click="loadMoreHistory"
|
|||
|
|
>加载更早版本({{ history.length }} / {{ historyTotal }})</el-button
|
|||
|
|
>
|
|||
|
|
</details>
|
|||
|
|
</template>
|
|||
|
|
<AssetPicker
|
|||
|
|
v-model="picker"
|
|||
|
|
:kinds="pickerKinds"
|
|||
|
|
@select="selected"
|
|||
|
|
/><AssetPreview v-model:asset="preview" />
|
|||
|
|
</section>
|
|||
|
|
</template>
|
|||
|
|
<style scoped>
|
|||
|
|
.editable-production {
|
|||
|
|
min-width: 0;
|
|||
|
|
}
|
|||
|
|
.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>
|