From d757aab517206d0a3c9755664cdb1457a77d3bef Mon Sep 17 00:00:00 2001 From: zhangheng Date: Tue, 31 Mar 2026 10:39:56 +0800 Subject: [PATCH] fix(copy): fix --- .../label/components/PaperContainer.tsx | 22 ++++++++++++++++--- components/label/components/TopTools.tsx | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/components/label/components/PaperContainer.tsx b/components/label/components/PaperContainer.tsx index ad87855..5ce17ae 100644 --- a/components/label/components/PaperContainer.tsx +++ b/components/label/components/PaperContainer.tsx @@ -1311,7 +1311,7 @@ const PaperContainer = ( }, hollow.map((item: any) => item.map((p: any) => { - if (paper instanceof paper.Segment) { + if (p instanceof paper.Segment) { return [ p.point.x / activeScale, p.point.y / activeScale, @@ -1376,8 +1376,10 @@ const PaperContainer = ( let findIndexInArr = arr.findIndex((v) => v[0] === id) let oldData = arr.find((a) => a[0] === id)! let arr2 = needCopyMap.get(needCopyCategoryIds[index])! + let copiedItem = arr2.find((b: any) => b[0] === id) + if (!copiedItem) return let newData = { - ...arr2.find((b: any) => b[0] === id), + ...copiedItem[2], uid: oldData[2].uid, create_timestamp: oldData[2].create_timestamp, first_modified_timestamp: @@ -1444,7 +1446,21 @@ const PaperContainer = ( data.set(imageId, newCategoryMap) } } else { - data.set(imageId, needCopyMap) + let newCategoryMap = new Map() + for (let [key, needCopyItemsArr] of needCopyMap) { + let arr = needCopyItemsArr.map((item: any) => [ + item[0], + item[1].map((path: any) => + path.map(([x, y]: any) => [x * picScale, y * picScale]) + ), + item[2], + item[3].map((path: any) => + path.map(([x, y]: any) => [x * picScale, y * picScale]) + ), + ]) + newCategoryMap.set(key, arr) + } + data.set(imageId, newCategoryMap) } }) notifications.show({ message: "倍刢成功", color: "green" }) diff --git a/components/label/components/TopTools.tsx b/components/label/components/TopTools.tsx index 0526d72..ae55a0d 100644 --- a/components/label/components/TopTools.tsx +++ b/components/label/components/TopTools.tsx @@ -1827,7 +1827,7 @@ const TopTools = ( - + {activeImage}