Przeglądaj źródła

增加轨迹校验

Michael Wang 3 lat temu
rodzic
commit
4cda168d76

+ 14 - 2
src/features/mark/MarkDrawTrack.vue

@@ -30,6 +30,7 @@
 import type { SpecialTag, Track } from "@/types";
 import { toRefs, watch } from "vue";
 import { store } from "@/store/store";
+import { message } from "ant-design-vue";
 
 const props = defineProps<{
   trackList: Array<Track>;
@@ -44,9 +45,20 @@ const { trackList } = toRefs(props);
 const computeTopAndLeft = (track: Track | SpecialTag) => {
   const topInsideSlice = track.offsetY - props.dy;
   const leftInsideSlice = track.offsetX - props.dx;
+  const topInsideSliceRatio = topInsideSlice / props.sliceImageHeight;
+  const leftInsideSliceRatio = leftInsideSlice / props.sliceImageWidth;
+  if (
+    topInsideSliceRatio < 0 ||
+    topInsideSliceRatio > 1 ||
+    leftInsideSliceRatio < 0 ||
+    leftInsideSliceRatio > 1
+  ) {
+    void message.error("轨迹坐标有误,可能是图片被修改过,请联系管理员!");
+  }
+
   return {
-    top: (topInsideSlice / props.sliceImageHeight) * 100 + "%",
-    left: (leftInsideSlice / props.sliceImageWidth) * 100 + "%",
+    top: topInsideSliceRatio * 100 + "%",
+    left: leftInsideSliceRatio * 100 + "%",
     "font-size":
       (store.setting.uiSetting["score.fontSize.scale"] || 1) *
         store.setting.uiSetting["answer.paper.scale"] *

+ 14 - 2
src/features/student/studentInspect/MarkDrawTrack.vue

@@ -26,6 +26,7 @@
 import type { SpecialTag, Track } from "@/types";
 import { store } from "@/store/store";
 import { toRefs, watch } from "vue";
+import { message } from "ant-design-vue";
 
 const props = defineProps<{
   trackList: Array<Track>;
@@ -41,9 +42,20 @@ const focusedTrack = (track: Track) => {
 const computeTopAndLeft = (track: Track | SpecialTag) => {
   const topInsideSlice = track.offsetY;
   const leftInsideSlice = track.offsetX;
+  const topInsideSliceRatio = topInsideSlice / props.originalImageHeight;
+  const leftInsideSliceRatio = leftInsideSlice / props.originalImageWidth;
+  if (
+    topInsideSliceRatio < 0 ||
+    topInsideSliceRatio > 1 ||
+    leftInsideSliceRatio < 0 ||
+    leftInsideSliceRatio > 1
+  ) {
+    void message.error("轨迹坐标有误,可能是图片被修改过,请联系管理员!");
+  }
+
   return {
-    top: (topInsideSlice / props.originalImageHeight) * 100 + "%",
-    left: (leftInsideSlice / props.originalImageWidth) * 100 + "%",
+    top: topInsideSliceRatio * 100 + "%",
+    left: leftInsideSliceRatio * 100 + "%",
     "font-size":
       (store.setting.uiSetting["score.fontSize.scale"] || 1) *
         store.setting.uiSetting["answer.paper.scale"] *