refactor: code improve

This commit is contained in:
katherinehhh 2023-07-31 16:34:11 +08:00
parent 3a4857b070
commit e2b1fdf963

View File

@ -52,7 +52,7 @@ export const useCollectionState = (currentCollectionName: string) => {
type: 'duplicate', type: 'duplicate',
tag: compile(field.uiSchema?.title) || field.name, tag: compile(field.uiSchema?.title) || field.name,
}; };
const option = { const option: any = {
...node, ...node,
title: React.createElement(TreeNode, node), title: React.createElement(TreeNode, node),
key: prefix ? `${prefix}.${field.name}` : field.name, key: prefix ? `${prefix}.${field.name}` : field.name,
@ -73,6 +73,7 @@ export const useCollectionState = (currentCollectionName: string) => {
}); });
} else if (['hasOne', 'hasMany'].includes(field.type)) { } else if (['hasOne', 'hasMany'].includes(field.type)) {
option.isLeaf = false; option.isLeaf = false;
option.disabled = true;
option['children'] = traverseFields(field.target, { option['children'] = traverseFields(field.target, {
depth: depth + 1, depth: depth + 1,
maxDepth, maxDepth,