- 新增 hooks/ 目录,包含三个专用 Hook: * useVoiceGeneration - 语音生成和校验逻辑 * useDigitalHumanGeneration - 数字人视频生成逻辑 * useIdentifyFaceController - 协调两个子 Hook 的控制器 - 新增 types/identify-face.ts 完整类型定义 - 重构 IdentifyFace.vue 使用 hooks 架构: * 视图层与业务逻辑分离 * 状态管理清晰化 * 模块解耦,逻辑清晰 - 遵循单一职责原则,每个 Hook 只负责一个领域 - 提升代码可测试性和可维护性 - 支持两种视频素材来源:素材库选择和直接上传 - 实现语音生成优先校验的业务规则 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
113 lines
2.3 KiB
Vue
113 lines
2.3 KiB
Vue
<template>
|
|
<div class="result-panel">
|
|
<div v-if="!previewVideoUrl" class="result-placeholder">
|
|
<h3>生成的视频将在这里显示</h3>
|
|
</div>
|
|
|
|
<div v-else class="result-content">
|
|
<div class="result-section">
|
|
<h3>生成的数字人视频</h3>
|
|
<video :src="previewVideoUrl" controls class="generated-video"></video>
|
|
<div class="video-actions">
|
|
<a-button type="primary" @click="downloadVideo">下载视频</a-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted } from 'vue'
|
|
import { message } from 'ant-design-vue'
|
|
import { getDigitalHumanTask } from '@/api/digitalHuman'
|
|
|
|
const props = defineProps({
|
|
taskId: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
})
|
|
|
|
const emit = defineEmits(['videoLoaded'])
|
|
|
|
const previewVideoUrl = ref('')
|
|
|
|
const loadLastTask = async () => {
|
|
try {
|
|
const lastTaskId = localStorage.getItem('digital_human_last_task_id')
|
|
if (!lastTaskId) return
|
|
|
|
const res = await getDigitalHumanTask(lastTaskId)
|
|
if (res.code === 0 && res.data) {
|
|
const task = res.data
|
|
|
|
if (task.status === 'SUCCESS' && task.resultVideoUrl) {
|
|
previewVideoUrl.value = task.resultVideoUrl
|
|
emit('videoLoaded', task.resultVideoUrl)
|
|
}
|
|
}
|
|
} catch (error) {
|
|
localStorage.removeItem('digital_human_last_task_id')
|
|
}
|
|
}
|
|
|
|
const downloadVideo = () => {
|
|
if (!previewVideoUrl.value) return message.warning('没有可下载的视频')
|
|
const link = document.createElement('a')
|
|
link.href = previewVideoUrl.value
|
|
link.download = `数字人视频_${Date.now()}.mp4`
|
|
link.click()
|
|
}
|
|
|
|
defineExpose({
|
|
loadLastTask,
|
|
previewVideoUrl
|
|
})
|
|
|
|
onMounted(async () => {
|
|
await loadLastTask()
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.result-panel {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
}
|
|
|
|
.result-placeholder {
|
|
min-height: 400px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
.result-content {
|
|
color: #fff;
|
|
}
|
|
|
|
.result-section {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.result-section h3 {
|
|
margin-bottom: 12px;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.generated-video {
|
|
width: 100%;
|
|
max-height: 400px;
|
|
border-radius: 8px;
|
|
margin-top: 12px;
|
|
}
|
|
|
|
.video-actions {
|
|
margin-top: 16px;
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
</style>
|