import { ref } from "vue";
export { useTopicMode } from "./mode";
export { useAudioSet } from "./audio";
import { useSubjectList } from "./list";
import { useSubjectCheck } from "./wrong";

export const useSubjectShowLogic = (type: ExerciseType.ListType) => {
	const { subjectList, subjectTotal, currentSubject, currentSubjectIndex } = useSubjectList(type); //获取题目列表

	/**下一题数据请求锁 */
	const nextBtnState = ref(true);

	/** 展示下一题 */
	const nextSubject = async () => {
		if (currentSubjectIndex.value < subjectList.value.length - 1) {
			currentSubjectIndex.value++;
		}
	};

	/** 展示上一题  */
	const lastSubject = () => {
		currentSubjectIndex.value > 0 && currentSubjectIndex.value--;
	};
	const initSubject = ()=>{
		currentSubjectIndex.value =0
	}
	const { trueNum, falseNum, isJumpNext, userAnswerChange, addCurrentQuestion, skillsShow, officialShow } = useSubjectCheck(currentSubject, nextSubject,type);

	return {
		currentSubject,
		currentSubjectIndex,
		subjectTotal,
		nextSubject,
		lastSubject,
		initSubject,
		trueNum,
		falseNum,
		isJumpNext,
		userAnswerChange,
		addCurrentQuestion,
		skillsShow,
		officialShow,
		subjectList
	
	};
};
