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
+8
View File
@@ -7,12 +7,20 @@ from app.schemas.screen import Layout, Screen
class MoveHandler(BaseActionHandler[MoveAction]):
def apply(self, screen: Screen, action: MoveAction) -> Screen:
# 确认移动目标存在,并取得大屏副本及副本中的目标节点
result, target = self.copy_target(screen, action.target_id)
# 将现有布局转成字典,保留尺寸和其他布局字段
layout = target.layout.model_dump()
# 在原坐标上叠加相对位移,不将 delta_x 和 delta_y 当作绝对坐标
layout["x"] += action.delta_x
layout["y"] += action.delta_y
# 重新校验计算结果,防止浮点溢出产生无效坐标
target.layout = Layout.model_validate(layout)
# 返回移动后的大屏副本,供下一条动作继续使用
return result