<template>
	<component :is="currentComponent" @next="next" v-model:userTestData="userTestData"></component>
</template>

<script lang="ts" setup>
import initMockTest from "./components/initMockTest.vue";
import mockTestEnd from "./components/mockTestEnd.vue";
import startTest from "./components/startTest.vue";
import { useRouter } from "vue-router";
import { ref, reactive } from "vue";
const router = useRouter();
const vehicle = useRouter().currentRoute.value.query.vehicle as string; //路由qvehicle参数
const subject = useRouter().currentRoute.value.query.subject as string; //路由subject参数
const userTestData = ref({
	testScores: 0,
	useTime: 0,
});
//清除错题的缓存
window.localStorage.setItem(vehicle+subject,"[]");

const currentComponent = ref<any>(initMockTest);
const comIndex = ref(0);
const next = () => {
	comIndex.value = (comIndex.value + 1) % 3;
	switch (comIndex.value) {
		case 0:
			currentComponent.value = initMockTest;
			break;
		case 1:
			currentComponent.value = startTest;
			break;
		case 2:
			currentComponent.value = mockTestEnd;
			break;
	}
};
</script>

<style scoped lang="scss"></style>
