import { ref, computed } from 'vue'; import { defineStore } from 'pinia'; export const useGradeStore = defineStore('grade', () => { const examInfo = ref(null); const examDetail = ref([]); const examType = ref({ 1: '单选题', 2: '多选题', 3: '判断题', 4: '填空题', 5: '简答题', 6: '语音题', 7: '计算题', 8: '分析题', }); const currentType = ref(1); const currentIndex = ref(0); const getActiveQuestion = computed(() => { const temp = examDetail.value.find(item => item.questionType === currentType.value); if (temp) { return temp.questionList[currentIndex.value]; } }); const setExamInfo = (info) => { examInfo.value = info; }; const setExamDetail = (detail) => { examDetail.value = detail; }; const initExam = () => { currentIndex.value = 0; currentType.value = 1; } return { examInfo, examDetail, examType, currentType, currentIndex, initExam, getActiveQuestion, setExamInfo, setExamDetail, }; });