Skip to content

Commit 6fe5285

Browse files
committed
feat: 节点操作日志
1 parent 8dc4ae7 commit 6fe5285

17 files changed

Lines changed: 486 additions & 84 deletions

src/components/flow/nodes/GroupNode.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ const GroupContent = memo(
6666
);
6767

6868
const handleTitleBlur = useCallback(() => {
69-
saveHistory(0);
70-
}, [saveHistory]);
69+
saveHistory(0, {
70+
category: "group",
71+
action: "update",
72+
description: "编辑分组标题",
73+
targetIds: [nodeId],
74+
});
75+
}, [saveHistory, nodeId]);
7176

7277
return (
7378
<div

src/components/flow/nodes/StickerNode.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,13 @@ const StickerContent = memo(
8080
// 退出编辑
8181
const handleBlur = useCallback(() => {
8282
setEditing(false);
83-
saveHistory(0);
84-
}, [saveHistory]);
83+
saveHistory(0, {
84+
category: "node",
85+
action: "update",
86+
description: "编辑便签内容",
87+
targetIds: [nodeId],
88+
});
89+
}, [saveHistory, nodeId]);
8590

8691
// 内容变化
8792
const handleContentChange = useCallback(

src/components/flow/nodes/components/NodeContextMenu.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ export const NodeContextMenu = memo<NodeContextMenuProps>(
5656
if (updatedNode) {
5757
useFlowStore.getState().setTargetNode(updatedNode);
5858
}
59-
saveHistory(0);
59+
saveHistory(0, {
60+
category: "node",
61+
action: "update",
62+
description: "JSON 编辑节点数据",
63+
targetIds: [node.id],
64+
});
6065
},
6166
[node]
6267
);

src/components/flow/nodes/nodeContextMenu.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ function handleSetNodeDirection(
156156
return n;
157157
});
158158
setNodes(newNodes);
159-
saveHistory(0);
159+
saveHistory(0, {
160+
category: "node",
161+
action: "update",
162+
description: "设置端点位置",
163+
targetIds: [node.id],
164+
});
160165
message.success(
161166
`端点位置已设置为「${
162167
HANDLE_DIRECTION_OPTIONS.find((o) => o.value === direction)?.label
@@ -179,7 +184,12 @@ function handleUngroupNodes(node: NodeContextMenuNode) {
179184
/**更改分组颜色处理器 */
180185
function handleSetGroupColor(node: NodeContextMenuNode, color: string) {
181186
useFlowStore.getState().setNodeData(node.id, "direct", "color", color);
182-
useFlowStore.getState().saveHistory(0);
187+
useFlowStore.getState().saveHistory(0, {
188+
category: "group",
189+
action: "update",
190+
description: "更改分组颜色",
191+
targetIds: [node.id],
192+
});
183193
}
184194

185195
/**更改便签颜色处理器 */
@@ -190,7 +200,12 @@ function handleSetStickerColor(
190200
if (node.type !== NodeTypeEnum.Sticker) return;
191201

192202
useFlowStore.getState().setNodeData(node.id, "sticker", "color", color);
193-
useFlowStore.getState().saveHistory(0);
203+
useFlowStore.getState().saveHistory(0, {
204+
category: "node",
205+
action: "update",
206+
description: "更改便签颜色",
207+
targetIds: [node.id],
208+
});
194209
}
195210

196211
/**复制便签内容处理器 */

src/components/panels/main/FieldPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ function FieldPanel() {
164164
if (updatedNode) {
165165
useFlowStore.getState().setTargetNode(updatedNode);
166166
}
167-
saveHistory(0);
167+
saveHistory(0, {
168+
category: "node",
169+
action: "update",
170+
description: "JSON 编辑节点数据",
171+
targetIds: [currentNode.id],
172+
});
168173
},
169174
[currentNode],
170175
);

src/components/panels/main/InlineFieldPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ function InlineFieldPanel() {
104104
if (updatedNode) {
105105
useFlowStore.getState().setTargetNode(updatedNode);
106106
}
107-
saveHistory(0);
107+
saveHistory(0, {
108+
category: "node",
109+
action: "update",
110+
description: "JSON 编辑节点数据",
111+
targetIds: [currentNode.id],
112+
});
108113
},
109114
[currentNode],
110115
);

src/components/panels/node-editors/GroupEditor.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ export const GroupEditor = memo(
4444
const onColorChange = useCallback(
4545
(value: GroupColorTheme) => {
4646
setNodeData(currentNode.id, "direct", "color", value);
47-
saveHistory(0);
47+
saveHistory(0, {
48+
category: "group",
49+
action: "update",
50+
description: "更改分组颜色",
51+
targetIds: [currentNode.id],
52+
});
4853
},
4954
[currentNode.id, setNodeData, saveHistory],
5055
);

src/components/panels/node-editors/StickerEditor.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ export const StickerEditor = memo(
5858
const onColorChange = useCallback(
5959
(value: StickerColorTheme) => {
6060
setNodeData(currentNode.id, "sticker", "color", value);
61-
saveHistory(0);
61+
saveHistory(0, {
62+
category: "node",
63+
action: "update",
64+
description: "更改便签颜色",
65+
targetIds: [currentNode.id],
66+
});
6267
},
6368
[currentNode.id, setNodeData, saveHistory],
6469
);

0 commit comments

Comments
 (0)