diff --git a/src/components/Library/LibraryFileDialog.vue b/src/components/Library/LibraryFileDialog.vue index 6cf73d0..c3e1c7d 100644 --- a/src/components/Library/LibraryFileDialog.vue +++ b/src/components/Library/LibraryFileDialog.vue @@ -164,7 +164,7 @@ const generateClick = async () => { }) try { - const response = await fetch('/study-api/library/knowledge', { + const response = await fetch('/study-api/agent/knowledge', { method: 'POST', headers: { 'Content-Type': 'application/json' diff --git a/src/components/Library/LibraryFileList.vue b/src/components/Library/LibraryFileList.vue index 04275f0..5b17fd0 100644 --- a/src/components/Library/LibraryFileList.vue +++ b/src/components/Library/LibraryFileList.vue @@ -29,6 +29,7 @@ import { Delete, Edit, Picture, Document, Aim } from '@element-plus/icons-vue' import { useLibraryStore } from '@/stores/library.ts' import { usePracticeStore } from '@/stores/practice.ts' +import { useQuestionStore } from '@/stores/question.ts' import type { ILibraryFile } from '@/types/library.ts' import LibraryFilter from '@/components/Library/LibraryFilter.vue' import { computed } from 'vue' @@ -38,6 +39,7 @@ import { ElLoading, ElMessage } from 'element-plus' const libraryStore = useLibraryStore() const practiceStore = usePracticeStore() +const questionStore = useQuestionStore() const filterLibraryFileList = computed(() => { const subject = libraryStore.selectedSubject @@ -62,12 +64,12 @@ const trainClick = async (file: ILibraryFile) => { await generateQuestion() practiceStore.hasStart = true practiceStore.hasSubmit = false - practiceStore.checkList = [] + questionStore.checkList = [] } const generateQuestion = async () => { - practiceStore.questionContent = '' - practiceStore.hasGenerateQuestion = false + questionStore.questionContent = '' + questionStore.hasGenerateQuestion = false const loading = ElLoading.service({ lock: true, @@ -76,7 +78,7 @@ const generateQuestion = async () => { }) try { - const response = await fetch('/study-api/library/question', { + const response = await fetch('/study-api/agent/question', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -96,13 +98,13 @@ const generateQuestion = async () => { while (true) { const { value, done } = await reader.read() if (done) break - practiceStore.questionContent += decoder.decode(value, { stream: true }) + questionStore.questionContent += decoder.decode(value, { stream: true }) } ElMessage.success('生成完成') - practiceStore.hasGenerateQuestion = true + questionStore.hasGenerateQuestion = true - practiceStore.questionList = JSON.parse(practiceStore.questionContent) + questionStore.questionList = JSON.parse(questionStore.questionContent) libraryStore.fileTrainDialogVisible = true } catch (error) { console.log(error) diff --git a/src/components/Library/LibraryFileTrainDialog.vue b/src/components/Library/LibraryFileTrainDialog.vue index 1bd85a5..494d8ee 100644 --- a/src/components/Library/LibraryFileTrainDialog.vue +++ b/src/components/Library/LibraryFileTrainDialog.vue @@ -2,177 +2,14 @@ - - - - - {{ q.type === 'single' ? '单选' : '多选' }} - - 第{{ idx + 1 }}题 - - - {{ q.question }} - - - - - {{ optLetter(oi) }}. {{ opt }} - - - - - - - {{ optLetter(oi) }}. {{ opt }} - - - - - - - 正确答案 {{ practiceStore.checkList[idx].answer.join('、') }} - - - - - - - 提交答案 - + - diff --git a/src/components/exam/ExamDialog.vue b/src/components/exam/ExamDialog.vue new file mode 100644 index 0000000..dc3a758 --- /dev/null +++ b/src/components/exam/ExamDialog.vue @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + 取消 + 确认 + + + + + diff --git a/src/components/question/QuestionList.vue b/src/components/question/QuestionList.vue new file mode 100644 index 0000000..f9a3a46 --- /dev/null +++ b/src/components/question/QuestionList.vue @@ -0,0 +1,177 @@ + + + + + + + {{ q.type === 'single' ? '单选' : '多选' }} + + 第{{ idx + 1 }}题 + + + {{ q.question }} + + + + + {{ optLetter(oi) }}. {{ opt }} + + + + + + + {{ optLetter(oi) }}. {{ opt }} + + + + + + + 正确答案 {{ questionStore.checkList[idx].answer.join('、') }} + + + + + + + 提交答案 + + + + + + + diff --git a/src/stores/exam.ts b/src/stores/exam.ts new file mode 100644 index 0000000..b3229ef --- /dev/null +++ b/src/stores/exam.ts @@ -0,0 +1,19 @@ +import { defineStore } from 'pinia' +import type { IExamConfig } from '@/types/exam.ts' + +export const useExamStore = defineStore('exam', { + state: () => ({ + hasStart: false, + hasSubmit: false, + dialogVisible: false, + config: {} as IExamConfig + }), + actions: { + getEmptyConfig(): IExamConfig { + return { + subject: '', + total: 50 + } + } + } +}) diff --git a/src/stores/practice.ts b/src/stores/practice.ts index a4a084e..2741dac 100644 --- a/src/stores/practice.ts +++ b/src/stores/practice.ts @@ -1,18 +1,13 @@ import { defineStore } from 'pinia' import { addPracticeRecordApi, queryPracticeRecordApi } from '@/apis/practice.ts' -import type { IPracticeCheck, IPracticeRecord } from '@/types/practice.ts' -import type { IQuestion } from '@/types/question.ts' +import type { IPracticeRecord } from '@/types/practice.ts' export const usePracticeStore = defineStore('practice', { state: () => ({ hasStart: false, hasSubmit: false, libraryFileId: 0, - hasGenerateQuestion: false, - questionContent: '', - questionList: [] as IQuestion[], recordList: [] as IPracticeRecord[], - checkList: [] as IPracticeCheck[], currentRecord: {} as IPracticeRecord }), actions: { diff --git a/src/stores/question.ts b/src/stores/question.ts new file mode 100644 index 0000000..c8b9bc1 --- /dev/null +++ b/src/stores/question.ts @@ -0,0 +1,15 @@ +import { defineStore } from 'pinia' +import type { IPracticeCheck, IPracticeRecord } from '@/types/practice.ts' +import type { IQuestion } from '@/types/question.ts' + +export const useQuestionStore = defineStore('question', { + state: () => ({ + hasStart: false, + hasSubmit: false, + hasGenerateQuestion: false, + questionContent: '', + questionList: [] as IQuestion[], + recordList: [] as IPracticeRecord[], + checkList: [] as IPracticeCheck[] + }) +}) diff --git a/src/types/exam.ts b/src/types/exam.ts new file mode 100644 index 0000000..49efef3 --- /dev/null +++ b/src/types/exam.ts @@ -0,0 +1,4 @@ +export interface IExamConfig { + subject: string; + total: number; +} diff --git a/src/views/Exam.vue b/src/views/Exam.vue index 98d3bf1..345339c 100644 --- a/src/views/Exam.vue +++ b/src/views/Exam.vue @@ -1,11 +1,37 @@ - - 考试中心 - 按学科进行综合检验,模拟真实考试环境 - - + + + + 考试中心 + 按学科进行综合检验,模拟真实考试环境 + + 开始考试 + + + + + \ No newline at end of file +import QuestionList from '@/components/question/QuestionList.vue' +import ExamDialog from '@/components/exam/ExamDialog.vue' +import { Aim } from '@element-plus/icons-vue' +import { useExamStore } from '@/stores/exam.ts' +import { useQuestionStore } from '@/stores/question.ts' +import { onMounted } from 'vue' + +const examStore = useExamStore() +const questionStore = useQuestionStore() + +onMounted(() => { + questionStore.questionList = [] +}) + +const examClick = () => { + questionStore.questionList = [] + examStore.config = examStore.getEmptyConfig() + examStore.dialogVisible = true +} +
按学科进行综合检验,模拟真实考试环境