100 lines
7.9 KiB
Vue
100 lines
7.9 KiB
Vue
<template>
|
||
<section class="continuity-panel" aria-label="镜头衔接">
|
||
<div class="continuity-heading"><strong>镜头衔接</strong><span>{{ info?.source ? `接第 ${info.source.episodeNumber} 集 · 分镜 ${info.source.shotNumber}` : '独立镜头' }}</span></div>
|
||
<p v-if="info?.stale" class="continuity-warning">前镜头版本或衔接状态已改变:本镜头当前视频需要核对,旧视频已保留。</p>
|
||
<p v-if="info?.hasPriorVideoWithoutContinuity" class="continuity-warning">此设置用于下一次生成;当前视频尚未应用衔接。</p>
|
||
<label>衔接方式
|
||
<select v-model="form.continuity_mode" :disabled="saving">
|
||
<option value="none">独立镜头 / 转场</option>
|
||
<option value="context">状态承接(允许换角度)</option>
|
||
<option value="first_frame">尾帧接续(同场景连续动作)</option>
|
||
</select>
|
||
</label>
|
||
<template v-if="form.continuity_mode !== 'none'">
|
||
<label>承接来源
|
||
<select v-model="form.continuity_source_id" :disabled="saving">
|
||
<option :value="null">自动:上一分镜(跨集取上一集结尾)</option>
|
||
<option v-for="candidate in info?.candidates || []" :key="candidate.id" :value="candidate.id">{{ candidate.label }}</option>
|
||
</select>
|
||
</label>
|
||
<p v-if="info?.source?.endState" class="continuity-state">前镜头结束状态:{{ info.source.endState }}</p>
|
||
<p v-else class="continuity-note">前镜头尚未填写结束状态,请结合实际视频核对;系统不会把文字设定当成已观察到的画面。</p>
|
||
</template>
|
||
<template v-if="form.continuity_mode === 'first_frame'">
|
||
<label>取前段结束前的画面
|
||
<select v-model="form.continuity_offset_ms" :disabled="saving"><option :value="50">0.05 秒</option><option :value="200">0.2 秒</option><option :value="500">0.5 秒</option><option :value="1000">1 秒</option><option :value="2000">2 秒</option><option :value="3000">3 秒</option></select>
|
||
</label>
|
||
<p class="continuity-note">支持本地 MiniMax-H3、H3-Hybrid、Wan2.2-I2V。生成时使用单张首帧,不同时传角色参考图;其他模型请选择状态承接。</p>
|
||
<button class="btn btn-sm" :disabled="dirty || saving || previewing || info?.source?.readiness !== 'ready'" @click="preview">{{ previewing ? '提取中…' : '预览前镜头尾帧' }}</button>
|
||
<p v-if="info?.source?.readiness === 'waiting_predecessor'" class="continuity-note">前镜头尚未完成;提交后会等待,不占用显卡队列。</p>
|
||
<p v-if="info?.source?.readiness === 'blocked_predecessor'" class="continuity-warning">前镜头生成失败,请先恢复或重新生成前镜头。</p>
|
||
</template>
|
||
<figure v-if="previewFrame || info?.usedFrame"><img :src="'/' + (previewFrame || info.usedFrame).replace(/^\//, '')" alt="衔接参考帧" /><figcaption>{{ previewFrame ? '前镜头取帧预览;下一次提交会核对来源版本' : '当前视频生成时使用的首帧' }}</figcaption></figure>
|
||
<label>本镜头开始状态<textarea v-model="form.continuity_start" maxlength="1200" rows="3" :disabled="saving" placeholder="人物站位、朝向、服装、伤势、持物手、动作起点…" /></label>
|
||
<label>本镜头结束状态<textarea v-model="form.continuity_end" maxlength="1200" rows="3" :disabled="saving" placeholder="交给下一镜头的状态;可在看过实际视频后修正" /></label>
|
||
<p v-if="error" role="alert" class="continuity-warning">{{ error }}</p>
|
||
<div class="continuity-actions"><span>{{ dirty ? '有未保存的衔接设置' : '衔接设置已保存' }}</span><button class="btn btn-sm" :disabled="!dirty || saving" @click="save">{{ saving ? '保存中…' : '保存衔接' }}</button></div>
|
||
<div v-if="waiting" class="continuity-wait"><span>{{ task?.stage === 'blocked_predecessor' ? '等待处理前镜头失败' : '等待前镜头完成' }}</span><button class="btn btn-sm" :disabled="saving" @click="cancelWaiting">取消等待</button></div>
|
||
</section>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { api } from '~/composables/useApi'
|
||
const props = defineProps<{ shot: any; task?: any }>()
|
||
const emit = defineEmits<{ saved: []; dirty: [value: boolean] }>()
|
||
const info = ref<any>(null), error = ref(''), saving = ref(false), previewing = ref(false), previewFrame = ref('')
|
||
const form = ref<any>({}), savedValue = ref('')
|
||
const dirty = computed(() => JSON.stringify(form.value) !== savedValue.value)
|
||
watch(() => form.value.continuity_mode, mode => { if (mode === 'none') form.value.continuity_source_id = null })
|
||
const waiting = computed(() => props.task?.status === 'processing' && ['waiting_predecessor', 'blocked_predecessor'].includes(props.task?.stage))
|
||
watch(dirty, value => emit('dirty', value))
|
||
async function load() {
|
||
const id = props.shot?.id
|
||
if (!id) return
|
||
try { const value = await api.get(`/storyboards/${id}/continuity`); if (props.shot?.id === id) { info.value = value; error.value = '' } }
|
||
catch (e: any) { if (props.shot?.id === id) error.value = e.message }
|
||
}
|
||
watch(() => props.shot?.id, () => {
|
||
info.value = null; error.value = ''; previewFrame.value = ''
|
||
form.value = { continuity_mode: props.shot?.continuity_mode || 'none', continuity_source_id: props.shot?.continuity_source_id ?? null,
|
||
continuity_start: props.shot?.continuity_start || '', continuity_end: props.shot?.continuity_end || '', continuity_offset_ms: props.shot?.continuity_offset_ms ?? 200 }
|
||
savedValue.value = JSON.stringify(form.value); emit('dirty', false); void load()
|
||
}, { immediate: true })
|
||
async function save() {
|
||
const id = props.shot.id, snapshot = JSON.stringify(form.value)
|
||
saving.value = true
|
||
try { const result = await api.put(`/storyboards/${id}/continuity`, JSON.parse(snapshot)); if (props.shot.id === id) { info.value = result; savedValue.value = snapshot; previewFrame.value = ''; error.value = '' }; emit('saved') }
|
||
catch (e: any) { if (props.shot.id === id) error.value = e.message }
|
||
finally { saving.value = false }
|
||
}
|
||
async function preview() {
|
||
const id = props.shot.id; previewing.value = true
|
||
try { const result = await api.post(`/storyboards/${id}/continuity/preview`); if (props.shot.id === id) { previewFrame.value = result.frame; error.value = '' } }
|
||
catch (e: any) { if (props.shot.id === id) error.value = e.message }
|
||
finally { previewing.value = false }
|
||
}
|
||
async function cancelWaiting() {
|
||
saving.value = true
|
||
try { await api.post(`/tasks/${props.task.id}/cancel-waiting`); emit('saved') }
|
||
catch (e: any) { error.value = e.message }
|
||
finally { saving.value = false }
|
||
}
|
||
let interval: ReturnType<typeof setInterval>
|
||
onMounted(() => { interval = setInterval(() => { if (!saving.value) void load() }, 10000) })
|
||
onBeforeUnmount(() => { clearInterval(interval); emit('dirty', false) })
|
||
</script>
|
||
|
||
<style scoped>
|
||
.continuity-panel { display:flex; flex-direction:column; gap:12px; border:1px solid var(--border, #ddd); border-radius:14px; padding:16px; margin:12px 0; background:var(--bg-1, #fff); }
|
||
.continuity-heading,.continuity-actions,.continuity-wait { display:flex; align-items:center; justify-content:space-between; gap:8px; }
|
||
.continuity-heading span,.continuity-actions span,figcaption { font-size:11px; color:var(--text-3, #777); }
|
||
label { display:flex; flex-direction:column; gap:6px; font-size:12px; font-weight:600; }
|
||
select,textarea { width:100%; box-sizing:border-box; background:var(--bg-0, #fff); color:var(--text-0, #222); border:1px solid var(--border, #ddd); border-radius:8px; padding:9px; font:inherit; font-weight:400; }
|
||
textarea { resize:vertical; line-height:1.55; }
|
||
p { margin:0; font-size:12px; line-height:1.6; }
|
||
.continuity-note,.continuity-state { color:var(--text-2, #666); }
|
||
.continuity-warning { color:#a1490a; background:#fff3e8; padding:9px; border-radius:8px; }
|
||
.continuity-wait { font-size:12px; padding-top:10px; border-top:1px solid var(--border, #ddd); }
|
||
figure { margin:0; } img { max-width:100%; max-height:220px; border-radius:8px; object-fit:contain; } figcaption { margin-top:5px; }
|
||
</style>
|