feat: 添加 Action 协议

This commit is contained in:
2026-09-23 15:33:28 +08:00
parent f0d33ff058
commit 5ef873bfe9
14 changed files with 284 additions and 25 deletions
+25
View File
@@ -0,0 +1,25 @@
"""设置组件的绝对尺寸"""
from typing import Literal, Self
from pydantic import Field, model_validator
from app.schemas.screen import PositiveNumber
from .base import BaseAction
class ResizeAction(BaseAction):
type: Literal["resize"] = "resize"
width: PositiveNumber | None = Field(
default=None, description="目标宽度,单位 px,省略或 null 表示保持原值"
)
height: PositiveNumber | None = Field(
default=None, description="目标高度,单位 px,省略或 null 表示保持原值"
)
@model_validator(mode="after")
def require_size(self) -> Self:
if self.width is None and self.height is None:
raise ValueError("resize 至少提供 width 或 height")
return self