Explorar el Código

fix type warnings

Michael Wang hace 4 años
padre
commit
85ac08a54a
Se han modificado 2 ficheros con 9 adiciones y 3 borrados
  1. 6 2
      src/components/mark/MarkBody.vue
  2. 3 1
      src/components/mark/store.ts

+ 6 - 2
src/components/mark/MarkBody.vue

@@ -89,7 +89,9 @@ export default defineComponent({
           (q) => q.score
         );
         markResult.markerScore =
-          markResult.scoreList.reduce((acc, v) => (acc += v * 100), 0) / 100;
+          markResult.scoreList
+            .filter((v): v is number => v !== null)
+            .reduce((acc, v) => (acc += v * 100), 0) / 100;
         store.markResults = [...store.markResults, markResult];
         // console.log("watcheffect markResult 2", markResult, store.markResults);
       }
@@ -246,7 +248,9 @@ export default defineComponent({
 
             const thisImageTrackList = markResult.trackList.filter(
               (t) =>
-                t.offsetIndex === store.currentTask.sliceUrls.indexOf(url) + 1
+                t.offsetIndex ===
+                (store.currentTask &&
+                  store.currentTask.sliceUrls.indexOf(url) + 1)
             );
 
             const dataUrl = canvas.toDataURL();

+ 3 - 1
src/components/mark/store.ts

@@ -129,7 +129,9 @@ watch(
       //   }
       // }, [0])
       markResult.markerScore =
-        markResult.scoreList.reduce((acc, v) => (acc += v * 100), 0) / 100;
+        markResult.scoreList
+          .filter((v): v is number => v !== null)
+          .reduce((acc, v) => (acc += v * 100), 0) / 100;
 
       // console.log(markResult.scoreList, markResult.markerScore);
     }