feat:更新考试模块
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user