|
@@ -1,13 +1,13 @@
|
|
|
import { message } from "ant-design-vue";
|
|
|
-import { ref } from "vue";
|
|
|
+import { ref, watch } from "vue";
|
|
|
import type { SliceImage } from "@/types";
|
|
|
import { useMarkStore } from "@/store";
|
|
|
import { loadImage } from "@/utils/utils";
|
|
|
import EventBus from "@/plugins/eventBus";
|
|
|
import useDraw from "./useDraw";
|
|
|
// 计算裁切图和裁切图上的分数轨迹和特殊标记轨迹
|
|
|
-export default function useSliceTrack() {
|
|
|
- const emit = defineEmits(["error"]);
|
|
|
+export default function useSliceTrack(hasMarkResultToRender = false) {
|
|
|
+ // const emit = defineEmits(["error"]);
|
|
|
|
|
|
const markStore = useMarkStore();
|
|
|
const { getDataUrlForSliceConfig, getDataUrlForSplitConfig } = useDraw();
|
|
@@ -66,12 +66,12 @@ export default function useSliceTrack() {
|
|
|
let accumTopHeight = 0;
|
|
|
let accumBottomHeight = 0;
|
|
|
const trackLists = hasMarkResultToRender
|
|
|
- ? markResult.trackList
|
|
|
- : markStore.currentTask.questionList.map((q) => q.trackList).flat();
|
|
|
+ ? markResult.markerTrackList
|
|
|
+ : markStore.currentTask.questionList.map((q) => q.markerTrackList).flat();
|
|
|
|
|
|
const tagLists = hasMarkResultToRender
|
|
|
- ? markResult.specialTagList ?? []
|
|
|
- : markStore.currentTask.specialTagList ?? [];
|
|
|
+ ? markResult.markerTagList ?? []
|
|
|
+ : markStore.currentTask.markerTagList ?? [];
|
|
|
|
|
|
const tempSliceImagesWithTrackList: Array<SliceImage> = [];
|
|
|
for (const sliceConfig of markStore.currentTask.sliceConfig) {
|
|
@@ -100,7 +100,7 @@ export default function useSliceTrack() {
|
|
|
url: dataUrl,
|
|
|
indexInSliceUrls: sliceConfig.i,
|
|
|
// 通过positionY来定位是第几张slice的还原,并过滤出相应的track
|
|
|
- trackList: thisImageTrackList.filter(
|
|
|
+ markerTrackList: thisImageTrackList.filter(
|
|
|
(t) =>
|
|
|
t.positionY >= accumTopHeight / theFinalHeight.value &&
|
|
|
t.positionY < accumBottomHeight / theFinalHeight.value
|
|
@@ -125,7 +125,7 @@ export default function useSliceTrack() {
|
|
|
// 测试是否所有的track和tag都在待渲染的tempSliceImagesWithTrackList中
|
|
|
const numOfTrackAndTagInData = trackLists.length + tagLists.length;
|
|
|
const numOfTrackAndTagInTempSlice = tempSliceImagesWithTrackList
|
|
|
- .map((v) => v.trackList.length + v.tagList.length)
|
|
|
+ .map((v) => v.markerTrackList.length + v.tagList.length)
|
|
|
.reduce((p, c) => p + c);
|
|
|
if (numOfTrackAndTagInData !== numOfTrackAndTagInTempSlice) {
|
|
|
console.warn({ tagLists, trackLists, tempSliceImagesWithTrackList });
|
|
@@ -137,7 +137,7 @@ export default function useSliceTrack() {
|
|
|
// 初次渲染,不做动画
|
|
|
sliceImagesWithTrackList.push(...tempSliceImagesWithTrackList);
|
|
|
// 没抽象好,这里不好做校验
|
|
|
- // const renderedTrackAndTagNumber = sliceImagesWithTrackList.map(s => s.trackList.length + s.tagList.length).reduce((p,c) => p+ c);
|
|
|
+ // const renderedTrackAndTagNumber = sliceImagesWithTrackList.map(s => s.markerTrackList.length + s.tagList.length).reduce((p,c) => p+ c);
|
|
|
// if(renderedTrackAndTagNumber === thisIma)
|
|
|
} else {
|
|
|
rotateBoard.value = 1;
|
|
@@ -211,13 +211,13 @@ export default function useSliceTrack() {
|
|
|
let accumBottomHeight = 0;
|
|
|
const tempSliceImagesWithTrackList: SliceImage[] = [];
|
|
|
const trackLists = hasMarkResultToRender
|
|
|
- ? markResult.trackList
|
|
|
+ ? markResult.markerTrackList
|
|
|
: (markStore.currentTask.questionList || [])
|
|
|
- .map((q) => q.trackList)
|
|
|
+ .map((q) => q.markerTrackList)
|
|
|
.flat();
|
|
|
const tagLists = hasMarkResultToRender
|
|
|
- ? markResult.specialTagList ?? []
|
|
|
- : markStore.currentTask.specialTagList ?? [];
|
|
|
+ ? markResult.markerTagList ?? []
|
|
|
+ : markStore.currentTask.markerTagList ?? [];
|
|
|
for (const url of markStore.currentTask.sliceUrls) {
|
|
|
for (const config of splitConfigPairs) {
|
|
|
const indexInSliceUrls =
|
|
@@ -251,7 +251,7 @@ export default function useSliceTrack() {
|
|
|
tempSliceImagesWithTrackList.push({
|
|
|
url: dataUrl,
|
|
|
indexInSliceUrls: markStore.currentTask.sliceUrls.indexOf(url) + 1,
|
|
|
- trackList: thisImageTrackList.filter(
|
|
|
+ markerTrackList: thisImageTrackList.filter(
|
|
|
(t) =>
|
|
|
t.positionY >= accumTopHeight / theFinalHeight.value &&
|
|
|
t.positionY < accumBottomHeight / theFinalHeight.value
|
|
@@ -282,7 +282,7 @@ export default function useSliceTrack() {
|
|
|
// 测试是否所有的track和tag都在待渲染的tempSliceImagesWithTrackList中
|
|
|
const numOfTrackAndTagInData = trackLists.length + tagLists.length;
|
|
|
const numOfTrackAndTagInTempSlice = tempSliceImagesWithTrackList
|
|
|
- .map((v) => v.trackList.length + v.tagList.length)
|
|
|
+ .map((v) => v.markerTrackList.length + v.tagList.length)
|
|
|
.reduce((p, c) => p + c);
|
|
|
if (numOfTrackAndTagInData !== numOfTrackAndTagInTempSlice) {
|
|
|
console.warn({ tagLists, trackLists, tempSliceImagesWithTrackList });
|
|
@@ -330,7 +330,7 @@ export default function useSliceTrack() {
|
|
|
sliceImagesWithTrackList.splice(0);
|
|
|
console.trace("render error ", error);
|
|
|
// 图片加载出错,自动加载下一个任务
|
|
|
- emit("error");
|
|
|
+ // emit("error");
|
|
|
} finally {
|
|
|
markStore.renderLock = false;
|
|
|
markStore.globalMask = false;
|
|
@@ -353,5 +353,10 @@ export default function useSliceTrack() {
|
|
|
{ deep: true }
|
|
|
);
|
|
|
|
|
|
- return { maxSliceWidth, theFinalHeight, sliceImagesWithTrackList };
|
|
|
+ return {
|
|
|
+ rotateBoard,
|
|
|
+ maxSliceWidth,
|
|
|
+ theFinalHeight,
|
|
|
+ sliceImagesWithTrackList,
|
|
|
+ };
|
|
|
}
|