diff --git a/src/views/QuestionGenerator.vue b/src/views/QuestionGenerator.vue index b8c72ff..9980d8d 100644 --- a/src/views/QuestionGenerator.vue +++ b/src/views/QuestionGenerator.vue @@ -24,25 +24,81 @@ const rawContent = ref(""); const cancelTokenSource = ref(null); // ── 参数配置 ── -const questionType = ref("choice"); // 'choice' | 'fillBlank' | 'translation' | 'reading' const difficulty = ref("medium"); // 'easy' | 'medium' | 'hard' const questionCount = ref(5); -const topicInput = ref(""); + +// 新增维度:教材章节、知识点、题型 +const textbookChapter = ref(""); // 教材章节(预设) +const customTextbookChapter = ref(""); // 自定义教材章节输入 +const selectedKnowledgePoints = ref([]); // 选中的知识点 +const customKnowledgePoint = ref(""); // 自定义知识点输入 +const questionFormat = ref("单项选择"); // 题型(预设) +const customQuestionFormat = ref(""); // 自定义题型输入 // ── 配置选项 ── -const TYPE_OPTIONS = [ - { value: "choice", label: "选择题", desc: "单项选择题" }, - { value: "fillBlank", label: "填空题", desc: "根据语境填空" }, - { value: "translation", label: "翻译题", desc: "英汉互译" }, - { value: "reading", label: "阅读理解", desc: "阅读文章并回答问题" }, +const DIFFICULTY_OPTIONS = [ + { value: "very_easy", label: "容易", color: "#10b981" }, + { value: "easy", label: "较易", color: "#34d399" }, + { value: "medium", label: "适中", color: "#f59e0b" }, + { value: "hard", label: "较难", color: "#f97316" }, + { value: "very_hard", label: "困难", color: "#ef4444" }, ]; -const DIFFICULTY_OPTIONS = [ - { value: "easy", label: "简单", color: "#10b981" }, - { value: "medium", label: "中等", color: "#f59e0b" }, - { value: "hard", label: "困难", color: "#ef4444" }, +// 教材章节预设选项 +const CHAPTER_OPTIONS = [ + { value: "Starter Unit1 You and Me", label: "Starter Unit1 You and Me" }, + { value: "Starter Unit2 Keep Tidy", label: "Starter Unit2 Keep Tidy" }, + { value: "Starter Unit3 Welcome!", label: "Starter Unit3 Welcome!" }, + { value: "Unit 1 You and Me", label: "Unit 1 You and Me" }, + { value: "Unit 2 We're Family!", label: "Unit 2 We're Family!" }, + { value: "Unit 3 My School", label: "Unit 3 My School" }, ]; +// 知识点预设选项 +const KNOWLEDGE_POINT_OPTIONS = [ + { value: "语法", label: "语法" }, + { value: "词汇", label: "词汇" }, + { value: "冠词", label: "冠词" }, + { value: "不定冠词", label: "不定冠词" }, + { value: "定冠词", label: "定冠词" }, + { value: "名词", label: "名词" }, + { value: "动词", label: "动词" }, + { value: "形容词", label: "形容词" }, + { value: "代词", label: "代词" }, + { value: "介词", label: "介词" }, + { value: "时态", label: "时态" }, + { value: "一般现在时", label: "一般现在时" }, + { value: "现在进行时", label: "现在进行时" }, + { value: "一般过去时", label: "一般过去时" }, + { value: "句型结构", label: "句型结构" }, + { value: "阅读理解", label: "阅读理解" }, + { value: "写作", label: "写作" }, +]; + +// 题型预设选项 +const FORMAT_OPTIONS = [ + { value: "单项选择", label: "单项选择" }, + { value: "完形填空", label: "完形填空" }, + { value: "句型转换", label: "句型转换" }, + { value: "词汇运用", label: "词汇运用" }, + { value: "翻译句子", label: "翻译句子" }, + { value: "阅读理解", label: "阅读理解" }, + { value: "书面表达", label: "书面表达" }, + { value: "短文填空", label: "短文填空" }, + { value: "语法填空", label: "语法填空" }, + { value: "选词填空", label: "选词填空" }, +]; + +// 切换知识点选中状态 +const toggleKnowledgePoint = (value) => { + const index = selectedKnowledgePoints.value.indexOf(value); + if (index > -1) { + selectedKnowledgePoints.value.splice(index, 1); + } else { + selectedKnowledgePoints.value.push(value); + } +}; + // ── 解析试题内容 ── const parsedQuestions = computed(() => { const raw = rawContent.value; @@ -111,19 +167,30 @@ function extractOptions(text) { // ── 构建请求体 ── const buildRequestBody = () => { - const typeLabel = TYPE_OPTIONS.find((t) => t.value === questionType.value)?.label || "选择题"; const difficultyLabel = DIFFICULTY_OPTIONS.find((d) => d.value === difficulty.value)?.label || "中等"; - const userPrompt = `请生成 ${questionCount.value} 道${difficultyLabel}难度的英语${typeLabel}${ - topicInput.value ? `,主题为:${topicInput.value}` : "" - }。 + // 构建知识点字符串:预设选项 + 自定义输入 + const allKnowledgePoints = [ + ...selectedKnowledgePoints.value, + ...(customKnowledgePoint.value ? [customKnowledgePoint.value] : []), + ]; + const knowledgePointStr = allKnowledgePoints.length > 0 ? allKnowledgePoints.join("、") : ""; + + // 教材章节:优先使用自定义输入,否则使用预设选择 + const chapterStr = customTextbookChapter.value || textbookChapter.value || ""; + + // 题型:优先使用自定义输入,否则使用预设选择 + const formatStr = customQuestionFormat.value || questionFormat.value || ""; + + const userPrompt = `请生成 ${questionCount.value} 道${difficultyLabel}难度的英语试题。 要求: -1. 题目类型:${typeLabel} +1. 题型:${formatStr} 2. 难度等级:${difficultyLabel} 3. 题目数量:${questionCount.value} 道 -${topicInput.value ? `4. 主题/知识点:${topicInput.value}` : ""} +${chapterStr ? `4. 教材章节:${chapterStr}` : ""} +${knowledgePointStr ? `5. 知识点:${knowledgePointStr}` : ""} 请严格按照指定的输出格式生成试题。`; @@ -218,10 +285,14 @@ const resetAll = () => { }; const loadExample = () => { - questionType.value = "choice"; difficulty.value = "medium"; questionCount.value = 3; - topicInput.value = "一般现在时"; + textbookChapter.value = "Starter Unit2 Keep Tidy"; + customTextbookChapter.value = ""; + selectedKnowledgePoints.value = ["语法", "冠词", "不定冠词"]; + customKnowledgePoint.value = ""; + questionFormat.value = "句型转换"; + customQuestionFormat.value = ""; }; const goBack = () => router.back(); @@ -287,24 +358,6 @@ onUnmounted(() => {