fix(store): rect

This commit is contained in:
2026-02-28 17:59:19 +08:00
parent cc9bea54e5
commit 5b13594a68
2 changed files with 104 additions and 23 deletions

View File

@@ -2354,15 +2354,32 @@ export const usePaperStore = create<PaperState>((set) => ({
}
}
} else if (brushPath instanceof paper.Path) {
if (brushPath.segments && brushPath.segments.length)
useLabelStore
.getState()
.setOperation(
brushPath.data.imageId,
brushPath.data.operationId,
[brushPath.data.id, [brushPath.segments], newDetail, []]
)
else {
if (brushPath.segments && brushPath.segments.length) {
const pathData = JSON.parse(
brushPath.exportJSON({ precision: 20 })
)
const brushSegments = pathData?.[1]?.segments
if (brushSegments?.length) {
useLabelStore
.getState()
.setOperation(
brushPath.data.imageId,
brushPath.data.operationId,
[brushPath.data.id, [brushSegments], newDetail, []]
)
} else {
usePaperSupportStore
.getState()
.removeMaskById(brushPath.data.id)
useLabelStore
.getState()
.deleteOperation(
brushPath.data.imageId,
brushPath.data.operationId,
brushPath.data.id
)
}
} else {
usePaperSupportStore.getState().removeMaskById(brushPath.data.id)
useLabelStore
.getState()
@@ -2407,15 +2424,32 @@ export const usePaperStore = create<PaperState>((set) => ({
category_id: Number(pointPath.data.operationId),
}
if (pointPath instanceof paper.Path) {
if (pointPath.segments && pointPath.segments.length)
useLabelStore
.getState()
.setOperation(
pointPath.data.imageId,
pointPath.data.operationId,
[pointPath.data.id, [pointPath.segments], newDetail, []]
)
else {
if (pointPath.segments && pointPath.segments.length) {
const pathData = JSON.parse(
pointPath.exportJSON({ precision: 20 })
)
const pointSegments = pathData?.[1]?.segments
if (pointSegments?.length) {
useLabelStore
.getState()
.setOperation(
pointPath.data.imageId,
pointPath.data.operationId,
[pointPath.data.id, [pointSegments], newDetail, []]
)
} else {
usePaperSupportStore
.getState()
.removeMaskById(pointPath.data.id)
useLabelStore
.getState()
.deleteOperation(
pointPath.data.imageId,
pointPath.data.operationId,
pointPath.data.id
)
}
} else {
usePaperSupportStore.getState().removeMaskById(pointPath.data.id)
useLabelStore
.getState()
@@ -3329,8 +3363,7 @@ export const usePaperStore = create<PaperState>((set) => ({
useTopToolsStore.getState().activeOperation,
[
rect.data.id,
// todo check
[rect?.segments.map((e) => e.point)],
[JSON.parse(rect.exportJSON({ precision: 20 }))[1]?.segments],
{
...initialDetail,
uid: usePermissionStore.getState().user_id,