You've already forked DataMate
refactor(DataAnnotation): 移除未使用的状态变量并优化选择器逻辑
- 删除未使用的 addChildTag 和 addSiblingTag 状态变量 - 将 Select 组件的值设置为 null 以重置选择状态 - 简化 handleAddNode 调用的处理逻辑 - 移除不再需要的状态管理代码以提高性能
This commit is contained in:
@@ -426,8 +426,6 @@ const TemplateConfigurationTreeEditor = ({
|
|||||||
const [selectedId, setSelectedId] = useState<string>(tree.id);
|
const [selectedId, setSelectedId] = useState<string>(tree.id);
|
||||||
const [parseError, setParseError] = useState<string | null>(null);
|
const [parseError, setParseError] = useState<string | null>(null);
|
||||||
const lastSerialized = useRef<string>("");
|
const lastSerialized = useRef<string>("");
|
||||||
const [addChildTag, setAddChildTag] = useState<string | undefined>();
|
|
||||||
const [addSiblingTag, setAddSiblingTag] = useState<string | undefined>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@@ -763,9 +761,8 @@ const TemplateConfigurationTreeEditor = ({
|
|||||||
<Select
|
<Select
|
||||||
placeholder="添加子节点"
|
placeholder="添加子节点"
|
||||||
options={tagOptions}
|
options={tagOptions}
|
||||||
value={addChildTag}
|
value={null}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setAddChildTag(undefined);
|
|
||||||
handleAddNode(value, "child");
|
handleAddNode(value, "child");
|
||||||
}}
|
}}
|
||||||
disabled={isStructureLocked}
|
disabled={isStructureLocked}
|
||||||
@@ -773,9 +770,8 @@ const TemplateConfigurationTreeEditor = ({
|
|||||||
<Select
|
<Select
|
||||||
placeholder="添加同级节点"
|
placeholder="添加同级节点"
|
||||||
options={tagOptions}
|
options={tagOptions}
|
||||||
value={addSiblingTag}
|
value={null}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setAddSiblingTag(undefined);
|
|
||||||
handleAddNode(value, "sibling");
|
handleAddNode(value, "sibling");
|
||||||
}}
|
}}
|
||||||
disabled={isStructureLocked || selectedNode.id === tree.id}
|
disabled={isStructureLocked || selectedNode.id === tree.id}
|
||||||
|
|||||||
Reference in New Issue
Block a user