Files

53 lines
2.9 KiB
Vue
Raw Permalink 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.
<template>
<section class="english-video-prompt">
<div class="english-head">
<strong>英文提示词 · MiniMax H3 提交用</strong>
<span class="english-state" :class="{ ready: status === 'ready' }">{{ status === 'ready' ? '已同步' : status === 'stale' ? '中文已修改,待更新' : '待生成' }}</span>
</div>
<p>画面、动作和运镜使用英文;中文对白与 @ 素材标记保持原样。提交前会自动补齐或更新英文版。</p>
<textarea v-if="draft" v-model="draft" class="textarea" rows="12" aria-label="英文视频提示词" :disabled="busy || status !== 'ready'" @blur="save" />
<div class="english-actions">
<button class="btn btn-sm" :disabled="busy || !shot.video_prompt" @click="generate">{{ busy ? '正在处理英文…' : status === 'ready' ? '重新翻译英文' : '生成 / 更新英文' }}</button>
<span v-if="message" role="status">{{ message }}</span>
</div>
</section>
</template>
<script setup lang="ts">
import { storyboardAPI } from '~/composables/useApi'
const props = defineProps<{ shot: any; configId?: number; model?: string; beforeAction?: () => Promise<void> }>()
const emit = defineEmits(['saved'])
const draft = ref(props.shot.video_prompt_en || ''), busy = ref(false), message = ref('')
const status = computed(() => props.shot.video_prompt_en_status || 'missing')
watch(() => props.shot.video_prompt_en, value => { draft.value = value || '' })
async function generate() {
if (busy.value) return
busy.value = true; message.value = ''
try {
await props.beforeAction?.()
const row = await storyboardAPI.englishPrompt(props.shot.id, { force: true, config_id: props.configId, model: props.model })
draft.value = row.video_prompt_en; message.value = '英文版已保存'; emit('saved')
} catch (error: any) { message.value = error.message || '英文生成失败,请重试' }
finally { busy.value = false }
}
async function save() {
if (busy.value || status.value !== 'ready' || draft.value === props.shot.video_prompt_en) return
busy.value = true; message.value = ''
try {
await props.beforeAction?.()
await storyboardAPI.update(props.shot.id, { video_prompt_en: draft.value, source_prompt: props.shot.video_prompt })
message.value = '英文修改已保存'; emit('saved')
} catch (error: any) { message.value = error.message || '保存失败,请检查后重试' }
finally { busy.value = false }
}
</script>
<style scoped>
.english-video-prompt { margin-top:20px; border-top:1px solid var(--border-color); padding-top:18px; }
.english-head,.english-actions { display:flex; align-items:center; flex-wrap:wrap; gap:10px; }
.english-head strong { font-size:14px; }
.english-state { font-size:12px; color:var(--orange); }
.english-state.ready { color:var(--green); }
p,.english-actions span { color:var(--text-3); font-size:12px; line-height:1.7; }
.textarea { width:100%; line-height:1.65; }
.english-actions { margin-top:10px; }
</style>