feat:完成重构和测试
This commit is contained in:
+10
-2
@@ -39,13 +39,21 @@ def merge_config(defaults: dict, overrides: dict) -> dict:
|
||||
|
||||
|
||||
def complete_add(action: AddAction, catalog: ComponentCatalog) -> AddAction:
|
||||
"""按 node.type 找物料补全新增组件,模型显式写出的字段优先,并按物料设置 sample_data"""
|
||||
"""按 node.type 找物料补全新增组件,模型显式写出的字段优先
|
||||
|
||||
sample_data 模型写了就以模型为准(只有它知道是否换成了自己的数据),没写时按物料设置
|
||||
"""
|
||||
material = find_material(catalog, action.node.type)
|
||||
if not DATA_BINDING_SUPPORTED and action.node.model_extra.get("dataId"):
|
||||
raise ValueError(DATA_BINDING_ERROR)
|
||||
overrides = action.node.model_dump(mode="json", exclude_unset=True)
|
||||
node = ScreenNode.model_validate(merge_config(material.template(), overrides))
|
||||
return action.model_copy(update={"node": node, "sample_data": material.sample_data})
|
||||
sample_data = (
|
||||
action.sample_data
|
||||
if "sample_data" in action.model_fields_set
|
||||
else material.sample_data
|
||||
)
|
||||
return action.model_copy(update={"node": node, "sample_data": sample_data})
|
||||
|
||||
|
||||
def run_batch(
|
||||
|
||||
Reference in New Issue
Block a user