|
|
@@ -33,6 +33,7 @@
|
|
|
:poem-content="currentPoemContent"
|
|
|
@user-input-submit="handleUserInputSubmit"
|
|
|
@single-choice-submit="handleSingleChoiceSubmit"
|
|
|
+ @write-reading-submit="handleWriteReadingSubmit"
|
|
|
@video-ended="handleVideoEnded"
|
|
|
@poem-reading-complete="handlePoemReadingComplete"
|
|
|
/>
|
|
|
@@ -101,6 +102,9 @@ const props = defineProps({
|
|
|
// 事件定义
|
|
|
const emit = defineEmits(['dialogueEnded', 'goBack']);
|
|
|
|
|
|
+const evaluationDialogueTypes = ['poem_reading', 'write_reading', 'recite_reading'];
|
|
|
+const isEvaluationDialogue = (type) => evaluationDialogueTypes.includes(type);
|
|
|
+
|
|
|
/** 状态定义 **/
|
|
|
// 对话位置状态
|
|
|
const currentSectionIndex = ref(0); // 当前章节索引
|
|
|
@@ -373,7 +377,7 @@ const playSequence = () => {
|
|
|
}
|
|
|
}, 500);
|
|
|
}
|
|
|
- } else if (currentDialogue.value?.type === 'poem_reading') {
|
|
|
+ } else if (isEvaluationDialogue(currentDialogue.value?.type)) {
|
|
|
showPoem.value = false;
|
|
|
} else {
|
|
|
playDialogueAudio(true);
|
|
|
@@ -481,7 +485,7 @@ const playNext = (isAutoPlay = false) => {
|
|
|
}
|
|
|
|
|
|
// 诗词朗读评价处理
|
|
|
- if (currentDialogue.value?.type === 'poem_reading') {
|
|
|
+ if (isEvaluationDialogue(currentDialogue.value?.type)) {
|
|
|
showPoem.value = false;
|
|
|
return true;
|
|
|
}
|
|
|
@@ -508,7 +512,7 @@ const playNext = (isAutoPlay = false) => {
|
|
|
playNext(isAutoPlay);
|
|
|
}, 100);
|
|
|
}
|
|
|
- } else if (currentDialogue.value?.type === 'poem_reading') {
|
|
|
+ } else if (isEvaluationDialogue(currentDialogue.value?.type)) {
|
|
|
showPoem.value = false;
|
|
|
} else {
|
|
|
playDialogueAudio(isPlaying.value);
|
|
|
@@ -548,7 +552,7 @@ const startPlayback = () => {
|
|
|
playNext();
|
|
|
}, 500);
|
|
|
}
|
|
|
- } else if (currentDialogue.value?.type === 'poem_reading') {
|
|
|
+ } else if (isEvaluationDialogue(currentDialogue.value?.type)) {
|
|
|
showPoem.value = false;
|
|
|
} else {
|
|
|
playDialogueAudio();
|
|
|
@@ -562,7 +566,7 @@ const startPlayback = () => {
|
|
|
const handleKeydown = (event) => {
|
|
|
if (showMask.value) return;
|
|
|
if (currentDialogue.value?.type === 'user') return;
|
|
|
- if (currentDialogue.value?.type === 'poem_reading') return;
|
|
|
+ if (isEvaluationDialogue(currentDialogue.value?.type)) return;
|
|
|
|
|
|
switch (event.key) {
|
|
|
case 'ArrowLeft':
|
|
|
@@ -612,6 +616,27 @@ const handleUserInputSubmit = async (data) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * 处理诗词仿写提交,并将原诗词与学生作品一并发送给 AI 评价。
|
|
|
+ * @param {Object} data - 学生输入数据
|
|
|
+ */
|
|
|
+const handleWriteReadingSubmit = async (data) => {
|
|
|
+ const originalPoem = currentDialogue.value?.content?.trim();
|
|
|
+ const imitation = data.content?.trim();
|
|
|
+ if (!originalPoem || !imitation) return;
|
|
|
+
|
|
|
+ await createAiChart();
|
|
|
+ if (!activeConversationId.value) return;
|
|
|
+
|
|
|
+ const content = `你是一位古诗词仿写指导老师。请根据“原诗词”和“学生仿写作品”,给出友善、具体、鼓励式的评价。\n\n原诗词:\n${originalPoem}\n\n学生仿写:\n${imitation}\n\n请从主题意境、结构句式、语言表达和创新性四方面评价。先肯定亮点,再指出1~2个可操作的改进建议;不苛求严格格律;控制在150字以内。`;
|
|
|
+
|
|
|
+ await doSendMessageStream({
|
|
|
+ conversationId: activeConversationId.value,
|
|
|
+ content,
|
|
|
+ contentAnswer: null,
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* 处理单选问题提交
|
|
|
* @param {Object} data - 用户选择数据
|