import { httpApp } from "@/plugins/axiosApp"; import { RichTextQuestion, UnionStore } from "@/types"; /** 清理复核任务 */ export async function getJSON(url: string) { return httpApp.get(url, { withCredentials: false }); } export async function getPaper(store: UnionStore) { const res = await getJSON(store.setting.subject.paperUrl); store.setting.subject.questions = []; if (res.data.questions) { // 云平台格式 const questions = res.data.questions; // TODO: add type for (const q of questions) { const tempQuestion = { unionOrder: q.mainNumber + "-" + q.subNumber, body: q.body, parentBody: q.parentBody, answer: [q.answer], } as RichTextQuestion; store.setting.subject.questions.push(tempQuestion); } } else { const details = res.data.details; for (let order1 of details) { for (let order2 of order1.questions) { if (order2.subQuestions) { for (let order3 of order2.subQuestions) { const tempQuestion = { unionOrder: order1.number + "-" + order2.number + "-" + order3.number, body: order3.body, parentBody: order2.body, answer: order3.answer, } as RichTextQuestion; store.setting.subject.questions.push(tempQuestion); } } else { const tempQuestion = { unionOrder: order1.number + "-" + order2.number, body: order2.body, parentBody: null, answer: order2.answer, } as RichTextQuestion; store.setting.subject.questions.push(tempQuestion); } } } } }