|
|
@@ -99,6 +99,7 @@ import {
|
|
|
sendChatMessageStream, textToSpeech
|
|
|
} from "@/api/questions.js";
|
|
|
import {Message} from "@/utils/message/Message.js";
|
|
|
+import {teacherList} from "@/api/teachers.js";
|
|
|
|
|
|
// 定义props
|
|
|
const props = defineProps({
|
|
|
@@ -109,6 +110,9 @@ const props = defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+// 本地数字人列表
|
|
|
+const localScriptRoles = ref([])
|
|
|
+
|
|
|
// 发送消息输入框
|
|
|
const prompt = ref(""); // prompt
|
|
|
|
|
|
@@ -772,7 +776,8 @@ const progressSteps = ref([
|
|
|
|
|
|
// 计算主讲下拉框选项
|
|
|
const teacherOptions = computed(() => {
|
|
|
- return props.scriptRoles.map(role => ({
|
|
|
+ const roles = props.scriptRoles.length > 0 ? props.scriptRoles : localScriptRoles.value;
|
|
|
+ return roles.map(role => ({
|
|
|
label: role.name,
|
|
|
value: role.name
|
|
|
}));
|
|
|
@@ -780,12 +785,33 @@ const teacherOptions = computed(() => {
|
|
|
|
|
|
// 计算助教下拉框选项
|
|
|
const assistantOptions = computed(() => {
|
|
|
- return props.scriptRoles.map(role => ({
|
|
|
+ const roles = props.scriptRoles.length > 0 ? props.scriptRoles : localScriptRoles.value;
|
|
|
+ return roles.map(role => ({
|
|
|
label: role.name,
|
|
|
value: role.name
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
+/**
|
|
|
+ * 获取角色列表
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+const getRoleList = async () => {
|
|
|
+ try {
|
|
|
+ let grade = localStorage.getItem('selectedGrade')
|
|
|
+ grade = grade ? grade : '小学低年级'
|
|
|
+ // 获取小学低年级AI数据
|
|
|
+ const listAiRes = await teacherList({ category: grade + 'AI' })
|
|
|
+ const listRes = await teacherList({ category: grade })
|
|
|
+ const listAi = listAiRes.data.list || []
|
|
|
+ const list = listRes.data.list || []
|
|
|
+ listAi.push(...list)
|
|
|
+ localScriptRoles.value = listAi
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取角色数据失败:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 下拉框配置
|
|
|
const dropdowns = ref([
|
|
|
{
|
|
|
@@ -918,9 +944,15 @@ const allStepsCompleted = computed(() => {
|
|
|
});
|
|
|
|
|
|
// 组件挂载时
|
|
|
-onMounted(() => {
|
|
|
+onMounted(async () => {
|
|
|
// 初始状态下不显示生成进度
|
|
|
showNewContainer.value = false;
|
|
|
+
|
|
|
+ // 如果父组件没有传递scriptRoles,则自己获取
|
|
|
+ if (props.scriptRoles.length === 0) {
|
|
|
+ await getRoleList();
|
|
|
+ }
|
|
|
+
|
|
|
// 初始化主讲下拉框选项
|
|
|
dropdowns.value[1].options = teacherOptions.value;
|
|
|
// 初始化助教下拉框选项
|