feat:新增代码注释

This commit is contained in:
2026-09-29 19:52:52 +08:00
parent ff8adba01b
commit af84485e8d
11 changed files with 224 additions and 7 deletions
+5 -1
View File
@@ -16,9 +16,13 @@ class BaseActionHandler(ABC, Generic[ActionT]):
raise NotImplementedError
def copy_target(self, screen: Screen, target_id: str) -> tuple[Screen, ScreenNode]:
# 先确认目标存在,再复制,避免修改原始快照
# 遍历节点
for index, node in enumerate(screen.nodes):
# 如果找到目标,复制完整大屏,并返回副本中同一位置的节点
if node.id == target_id:
result = screen.model_copy(deep=True)
# 返回副本内的节点引用,让调用方的修改直接体现在 result 中
return result, result.nodes[index]
# 遍历后仍未找到目标时明确报错,不能把无效动作当作执行成功
raise ValueError(f"目标组件不存在: {target_id}")