Преглед изворни кода

fixbug: 键盘模式提交错误

Michael Wang пре 4 година
родитељ
комит
1d03efbc62

+ 4 - 17
src/components/mark/MarkBoardKeyBoard.vue

@@ -66,19 +66,13 @@ export default defineComponent({
       const question = store.currentQuestion;
       if (!question) return [];
 
+      const remainScore = question.maxScore - (question.score || 0);
       const steps = [];
-      for (
-        let i = 0;
-        i <= question.maxScore - (question.score || 0);
-        i += question.intervalScore
-      ) {
+      for (let i = 0; i <= remainScore; i += question.intervalScore) {
         steps.push(i);
       }
-      if (
-        (question.maxScore - (question.score || 0)) % question.intervalScore !==
-        0
-      ) {
-        steps.push(question.maxScore - (question.score || 0));
+      if (remainScore % question.intervalScore !== 0) {
+        steps.push(remainScore);
       }
 
       return steps;
@@ -90,13 +84,6 @@ export default defineComponent({
         store.currentQuestion?.subNumber === question.subNumber
       );
     }
-    // 当题目改变时,重置当前分数
-    watch(
-      () => store.currentQuestion,
-      () => {
-        store.currentScore = undefined;
-      }
-    );
 
     let keyPressTimestamp = 0;
     let keys: string[] = [];

+ 1 - 0
src/components/mark/use/autoChooseFirstQuestion.ts

@@ -11,6 +11,7 @@ export function autoChooseFirstQuestion() {
   watch(
     () => store.currentTask,
     () => {
+      // FIXME: 此时取到的还是score:null,但是 chooseQuestion之后就变成了score:0
       const firstQuetion = store.currentTask?.questionList[0];
       firstQuetion && chooseQuestion(firstQuetion);
     }

+ 2 - 3
src/components/mark/use/keyboardAndMouse.ts

@@ -11,14 +11,13 @@ export function keyMouse() {
     }
   }
 
-  // TODO: findCurrentTaskMarkResult => store.currentMarkResult
-  const markResult = findCurrentTaskMarkResult();
-
   // 普通模式更新分数时
   watch(
     () => store.currentQuestion?.score,
     () => {
       if (store.setting.mode === ModeEnum.COMMON) {
+        // TODO: findCurrentTaskMarkResult => store.currentMarkResult
+        const markResult = findCurrentTaskMarkResult();
         if (markResult && store.currentTask) {
           const scoreList = store.currentTask.questionList.map(
             (q) => q.score || 0