1234567891011121314151617181920212223242526 |
- import { Question } from "@/types";
- import { store } from "../store";
- import { watch } from "vue";
- export function chooseQuestion(question: Question) {
- store.currentQuestion = question;
- }
- /** chooseQuestion 当currentTask改变是,自动选择第一题 */
- export function autoChooseFirstQuestion() {
- watch(
- () => store.currentTask,
- () => {
- // FIXME: 此时取到的还是score:null,但是 chooseQuestion之后就变成了score:0
- const firstQuestion = store.currentTask?.questionList[0];
- if (firstQuestion) {
- // const oldScore = firstQuestion.score;
- // console.log(oldScore);
- chooseQuestion(firstQuestion);
- // setTimeout(() => (firstQuestion.score = oldScore), 0);
- }
- }
- );
- return { chooseQuestion };
- }
|