|
|
@@ -101,15 +101,6 @@ import {
|
|
|
import {Message} from "@/utils/message/Message.js";
|
|
|
import {teacherList} from "@/api/teachers.js";
|
|
|
|
|
|
-// 定义props
|
|
|
-const props = defineProps({
|
|
|
- // 数字人列表
|
|
|
- scriptRoles: {
|
|
|
- type: Array,
|
|
|
- default: () => []
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
// 本地数字人列表
|
|
|
const localScriptRoles = ref([])
|
|
|
|
|
|
@@ -143,8 +134,8 @@ const lessonList = ref([
|
|
|
{id: '3', name: '课程总结'}
|
|
|
])
|
|
|
//主讲人、助讲人
|
|
|
-const selectedMainTeacher = ref('李白')
|
|
|
-const selectedAssistants = ref(['小智'])
|
|
|
+const selectedMainTeacher = ref('')
|
|
|
+const selectedAssistants = ref([''])
|
|
|
|
|
|
//脚本数据
|
|
|
const scriptData = reactive(
|
|
|
@@ -258,7 +249,8 @@ const generateScript = async () => {
|
|
|
try {
|
|
|
isGenerating.value = true
|
|
|
|
|
|
- const role = props.scriptRoles.find((r) => r.name === selectedMainTeacher.value)
|
|
|
+ const role = localScriptRoles.value.find((r) => r.name === selectedMainTeacher.value)
|
|
|
+
|
|
|
let content =
|
|
|
prompt.value +
|
|
|
'(主讲人:' + role.name +
|
|
|
@@ -267,10 +259,10 @@ const generateScript = async () => {
|
|
|
let zhujiang = []
|
|
|
|
|
|
selectedAssistants.value.forEach((rName) => {
|
|
|
- const assistantRole = props.scriptRoles.find((r) => r.name === rName)
|
|
|
+ const assistantRole = localScriptRoles.value.find((r) => r.name === rName)
|
|
|
zhujiang.push(assistantRole.name + '[' + assistantRole.description + ']')
|
|
|
})
|
|
|
- content += zhujiang.join(',') + ')'
|
|
|
+ content += zhujiang.join(',') + ');注意:给我的背景图提示词不允许出现主讲人和助讲人物形象。'
|
|
|
|
|
|
// 1. 创建对话
|
|
|
await createAiRoleIdConversation(13)
|
|
|
@@ -299,14 +291,14 @@ const generateScript = async () => {
|
|
|
progressSteps.value[0].completed = true;
|
|
|
progressSteps.value[0].active = false;
|
|
|
|
|
|
- content = "最后请给我围绕着这几节课的课程封面图描述词(coverImage)和课程名称(courseName)。"
|
|
|
+ content = "最后请给我围绕着这几节课的课程封面图描述词(coverImage)和课程名称(courseName),课程名字不能超过10个字。"
|
|
|
progressSteps.value[1].visible = true;
|
|
|
progressSteps.value[1].active = true;
|
|
|
let courseInfo = {}//存储课程信息
|
|
|
await doSendMessageStream(activeConversationId.value, content, courseInfo)
|
|
|
console.log("生成课程信息:", courseInfo)
|
|
|
scriptData.courseName = courseInfo.courseName
|
|
|
- scriptData.coverImage.prompt = courseInfo.coverImage
|
|
|
+ scriptData.coverImage = courseInfo.coverImage
|
|
|
progressSteps.value[1].completed = true;
|
|
|
progressSteps.value[1].active = false;
|
|
|
|
|
|
@@ -555,13 +547,20 @@ const generateCoverImage = async () => {
|
|
|
"height": 1024
|
|
|
})
|
|
|
console.log("生成封面图", response)
|
|
|
- const imageId = response.data
|
|
|
- if (typeof imageId === 'number' && !isNaN(imageId)) {
|
|
|
+ let imageId = response.data
|
|
|
+ // 处理不同格式的响应
|
|
|
+ if (typeof imageId === 'object' && imageId !== null) {
|
|
|
+ // 如果是对象,尝试获取id属性
|
|
|
+ imageId = imageId.id || imageId.imageId || imageId.data
|
|
|
+ }
|
|
|
+ // 转换为数字
|
|
|
+ imageId = Number(imageId)
|
|
|
+ if (!isNaN(imageId)) {
|
|
|
inProgressImageMap.value[imageId] = {
|
|
|
type: 'cover'
|
|
|
}
|
|
|
} else {
|
|
|
- console.error('无效的图片ID:', imageId)
|
|
|
+ console.error('无效的图片ID:', response.data)
|
|
|
scriptData.coverImage.generating = false
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -590,15 +589,22 @@ const generateImage = async (lessonIndex, sectionIndex) => {
|
|
|
"height": 1024
|
|
|
})
|
|
|
console.log("生成图片", res)
|
|
|
- const imageId = res.data
|
|
|
- if (typeof imageId === 'number' && !isNaN(imageId)) {
|
|
|
+ let imageId = res.data
|
|
|
+ // 处理不同格式的响应
|
|
|
+ if (typeof imageId === 'object' && imageId !== null) {
|
|
|
+ // 如果是对象,尝试获取id属性
|
|
|
+ imageId = imageId.id || imageId.imageId || imageId.data
|
|
|
+ }
|
|
|
+ // 转换为数字
|
|
|
+ imageId = Number(imageId)
|
|
|
+ if (!isNaN(imageId)) {
|
|
|
inProgressImageMap.value[imageId] = {
|
|
|
lessonIndex: lessonIndex,
|
|
|
sectionIndex: sectionIndex,
|
|
|
type: 'image'
|
|
|
}
|
|
|
} else {
|
|
|
- console.error('无效的图片ID:', imageId)
|
|
|
+ console.error('无效的图片ID:', res.data)
|
|
|
media.generating = false
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -753,7 +759,7 @@ const generateVoiceover = async (lessonIndex, sectionIndex, dialogueIndex) => {
|
|
|
|
|
|
dialogue.generatingVoiceover = true
|
|
|
|
|
|
- let role = props.scriptRoles.find((r) => r.name === dialogue.roleName)
|
|
|
+ let role = localScriptRoles.value.find((r) => r.name === dialogue.roleName)
|
|
|
if (!role) {
|
|
|
console.error('未找到角色:', dialogue.roleName)
|
|
|
dialogue.generatingVoiceover = false
|
|
|
@@ -790,7 +796,7 @@ const progressSteps = ref([
|
|
|
|
|
|
// 计算主讲下拉框选项
|
|
|
const teacherOptions = computed(() => {
|
|
|
- const roles = props.scriptRoles.length > 0 ? props.scriptRoles : localScriptRoles.value;
|
|
|
+ const roles = localScriptRoles.value.length > 0 ? localScriptRoles.value : localScriptRoles.value;
|
|
|
return roles.map(role => ({
|
|
|
label: role.name,
|
|
|
value: role.name
|
|
|
@@ -799,7 +805,7 @@ const teacherOptions = computed(() => {
|
|
|
|
|
|
// 计算助教下拉框选项
|
|
|
const assistantOptions = computed(() => {
|
|
|
- const roles = props.scriptRoles.length > 0 ? props.scriptRoles : localScriptRoles.value;
|
|
|
+ const roles = localScriptRoles.value.length > 0 ? localScriptRoles.value : localScriptRoles.value;
|
|
|
return roles.map(role => ({
|
|
|
label: role.name,
|
|
|
value: role.name
|
|
|
@@ -962,11 +968,8 @@ onMounted(async () => {
|
|
|
// 初始状态下不显示生成进度
|
|
|
showNewContainer.value = false;
|
|
|
|
|
|
- // 如果父组件没有传递scriptRoles,则自己获取
|
|
|
- if (props.scriptRoles.length === 0) {
|
|
|
- await getRoleList();
|
|
|
- }
|
|
|
-
|
|
|
+ await getRoleList();
|
|
|
+
|
|
|
// 初始化主讲下拉框选项
|
|
|
dropdowns.value[1].options = teacherOptions.value;
|
|
|
// 初始化助教下拉框选项
|