Skip to content

🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"

TypeScript

feat: 提取对话框组件 SceneSelector/CharacterSelector/PropSelector

Connoraa606da81b31
diff --git a/web/src/views/drama/professional/dialogs/CharacterSelector.vue b/web/src/views/drama/professional/dialogs/CharacterSelector.vue
new file mode 100644
index 0000000..9438ab8
--- /dev/null
+++ b/web/src/views/drama/professional/dialogs/CharacterSelector.vue
@@ -0,0 +1,77 @@
+<template>
+ <el-dialog :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" title="添加角色到镜头" width="800px">
+ <div class="character-selector-grid">
+ <div
+ v-for="char in characters"
+ :key="char.id"
+ class="character-card"
+ :class="{ selected: isInCurrentShot(char.id) }"
+ @click="$emit('toggle', char.id)"
+ >
+ <div class="character-avatar-large">
+ <img v-if="char.local_path" :src="getImageUrl(char)" :alt="char.name" />
+ <span v-else>{{ char.name?.[0] || '?' }}</span>
+ </div>
+ <div class="character-info">
+ <div class="character-name">{{ char.name }}</div>
+ <div class="character-role">{{ char.role || '角色' }}</div>
+ </div>
+ <div class="character-check" v-if="isInCurrentShot(char.id)">
+ <el-icon color="#409eff" :size="24"><Check /></el-icon>
+ </div>
+ </div>
+ <div v-if="characters.length === 0" class="empty-characters">
+ <el-empty description="暂无角色,请先在剧集中创建角色" />
+ </div>
+ </div>
+ <template #footer>
+ <el-button @click="$emit('update:modelValue', false)">关闭</el-button>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup lang="ts">
+import { Check } from '@element-plus/icons-vue'
+import { getImageUrl } from '@/utils/image'
+
+defineProps<{
+ modelValue: boolean
+ characters: any[]
+ isInCurrentShot: (id: number) => boolean
+}>()
+
+defineEmits<{
+ 'update:modelValue': [value: boolean]
+ toggle: [charId: number]
+}>()
+</script>
+
+<style scoped lang="scss">
+.character-selector-grid {
+ display: grid; grid-template-columns: repeat(3, 1fr);
+ gap: 12px; max-height: 420px; overflow-y: auto; padding: 4px;
+}
+.character-card {
+ display: flex; flex-direction: column; align-items: center;
+ gap: 6px; padding: 10px; border: 2px solid transparent;
+ border-radius: 8px; cursor: pointer;
+ transition: border-color 0.15s;
+ &.selected { border-color: #409eff; background: #ecf5ff; }
+ &:hover { border-color: #a0cfff; }
+
+ .character-avatar-large {
+ width: 64px; height: 64px; border-radius: 50%;
+ overflow: hidden; background: #f0f0f0;
+ display: flex; align-items: center; justify-content: center;
+ img { width: 100%; height: 100%; object-fit: cover; }
+ span { font-size: 22px; font-weight: 600; }
+ }
+ .character-info {
+ text-align: center;
+ .character-name { font-size: 13px; font-weight: 500; }
+ .character-role { font-size: 11px; color: #909399; }
+ }
+ .character-check { margin-top: 4px; }
+}
+.empty-characters { grid-column: 1/-1; }
+</style>
diff --git a/web/src/views/drama/professional/dialogs/PropSelector.vue b/web/src/views/drama/professional/dialogs/PropSelector.vue
new file mode 100644
index 0000000..c183834
--- /dev/null
+++ b/web/src/views/drama/professional/dialogs/PropSelector.vue
@@ -0,0 +1,76 @@
+<template>
+ <el-dialog :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" :title="$t('editor.addPropToShot')" width="800px">
+ <div class="character-selector-grid">
+ <div
+ v-for="prop in props"
+ :key="prop.id"
+ class="character-card"
+ :class="{ selected: isInCurrentShot(prop.id) }"
+ @click="$emit('toggle', prop.id)"
+ >
+ <div class="character-avatar-large">
+ <img v-if="prop.local_path" :src="getImageUrl(prop)" :alt="prop.name" />
+ <el-icon v-else :size="32"><Box /></el-icon>
+ </div>
+ <div class="character-info">
+ <div class="character-name">{{ prop.name }}</div>
+ <div class="character-role">{{ prop.type || $t('editor.props') }}</div>
+ </div>
+ <div class="character-check" v-if="isInCurrentShot(prop.id)">
+ <el-icon color="#409eff" :size="24"><Check /></el-icon>
+ </div>
+ </div>
+ <div v-if="props.length === 0" class="empty-characters">
+ <el-empty :description="$t('editor.noPropsAvailable')" />
+ </div>
+ </div>
+ <template #footer>
+ <el-button @click="$emit('update:modelValue', false)">{{ $t('common.close') }}</el-button>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup lang="ts">
+import { Check, Box } from '@element-plus/icons-vue'
+import { getImageUrl } from '@/utils/image'
+
+defineProps<{
+ modelValue: boolean
+ props: any[]
+ isInCurrentShot: (id: number) => boolean
+}>()
+
+defineEmits<{
+ 'update:modelValue': [value: boolean]
+ toggle: [propId: number]
+}>()
+</script>
+
+<style scoped lang="scss">
+.character-selector-grid {
+ display: grid; grid-template-columns: repeat(3, 1fr);
+ gap: 12px; max-height: 420px; overflow-y: auto; padding: 4px;
+}
+.character-card {
+ display: flex; flex-direction: column; align-items: center;
+ gap: 6px; padding: 10px; border: 2px solid transparent;
+ border-radius: 8px; cursor: pointer;
+ transition: border-color 0.15s;
+ &.selected { border-color: #409eff; background: #ecf5ff; }
+ &:hover { border-color: #a0cfff; }
+
+ .character-avatar-large {
+ width: 64px; height: 64px; border-radius: 50%;
+ overflow: hidden; background: #f0f0f0;
+ display: flex; align-items: center; justify-content: center;
+ img { width: 100%; height: 100%; object-fit: cover; }
+ }
+ .character-info {
+ text-align: center;
+ .character-name { font-size: 13px; font-weight: 500; }
+ .character-role { font-size: 11px; color: #909399; }
+ }
+ .character-check { margin-top: 4px; }
+}
+.empty-characters { grid-column: 1/-1; }
+</style>
diff --git a/web/src/views/drama/professional/dialogs/SceneSelector.vue b/web/src/views/drama/professional/dialogs/SceneSelector.vue
new file mode 100644
index 0000000..aaf9ac6
--- /dev/null
+++ b/web/src/views/drama/professional/dialogs/SceneSelector.vue
@@ -0,0 +1,67 @@
+<template>
+ <el-dialog :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" title="选择场景背景" width="800px">
+ <div class="scene-selector-grid">
+ <div
+ v-for="scene in scenes"
+ :key="scene.id"
+ class="scene-card"
+ :class="{ selected: currentSceneId === scene.id }"
+ @click="$emit('select', scene.id)"
+ >
+ <div class="scene-image">
+ <img v-if="hasImage(scene)" :src="getImageUrl(scene)" :alt="scene.location" />
+ <el-icon v-else :size="48" color="#ccc"><Picture /></el-icon>
+ </div>
+ <div class="scene-info">
+ <div class="scene-location">{{ scene.location }}</div>
+ <div class="scene-time">{{ scene.time }}</div>
+ </div>
+ </div>
+ <div v-if="scenes.length === 0" class="empty-scenes">
+ <el-empty description="暂无可用场景" />
+ </div>
+ </div>
+ </el-dialog>
+</template>
+
+<script setup lang="ts">
+import { Picture } from '@element-plus/icons-vue'
+import { getImageUrl, hasImage } from '@/utils/image'
+
+defineProps<{
+ modelValue: boolean
+ scenes: any[]
+ currentSceneId?: string
+}>()
+
+defineEmits<{
+ 'update:modelValue': [value: boolean]
+ select: [sceneId: number]
+}>()
+</script>
+
+<style scoped lang="scss">
+.scene-selector-grid {
+ display: grid; grid-template-columns: repeat(3, 1fr);
+ gap: 12px; max-height: 420px; overflow-y: auto; padding: 4px;
+}
+.scene-card {
+ display: flex; flex-direction: column;
+ border: 2px solid transparent; border-radius: 8px;
+ overflow: hidden; cursor: pointer; transition: border-color 0.15s;
+ &.selected { border-color: #409eff; }
+ &:hover { border-color: #a0cfff; }
+
+ .scene-image {
+ height: 80px; background: #f0f0f0;
+ display: flex; align-items: center; justify-content: center;
+ img { width: 100%; height: 100%; object-fit: cover; }
+ }
+ .scene-info {
+ padding: 6px 8px;
+ .scene-location { font-size: 13px; font-weight: 500; }
+ .scene-time { font-size: 11px; color: #909399; }
+ }
+}
+.empty-scenes { grid-column: 1/-1; }
+</style>