feat: 添加判断修改范围、规划和资源需求节点

This commit is contained in:
2026-09-23 16:51:10 +08:00
parent 5ef873bfe9
commit 5f5d733a9b
11 changed files with 566 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
"""显式注册动作处理器"""
from typing import Any
from app.actions.base import BaseActionHandler
from app.actions.move import MoveHandler
from app.actions.resize import ResizeHandler
from app.actions.update import UpdateHandler
from app.schemas.actions import Action
from app.schemas.screen import Screen
# 新增操作时在此注册,未实现的操作明确报错
ACTION_HANDLERS: dict[str, BaseActionHandler[Any]] = {
"move": MoveHandler(),
"resize": ResizeHandler(),
"update": UpdateHandler(),
}
def apply_action(screen: Screen, action: Action) -> Screen:
"""接收已通过 Schema 校验的动作,返回执行后的副本"""
handler = ACTION_HANDLERS.get(action.type)
if handler is None:
raise ValueError(f"尚未实现动作处理器: {action.type}")
return handler.apply(screen, action)