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
+22
View File
@@ -0,0 +1,22 @@
"""精确更新组件 props 或 style 下的一个字段"""
from typing import Annotated, Literal
from pydantic import Field, JsonValue
from app.schemas.base import NonBlankString
from .base import BaseAction
PathSegment = NonBlankString | Annotated[int, Field(ge=0)]
class UpdateAction(BaseAction):
type: Literal["update"] = "update"
section: Literal["props", "style"] = Field(description="允许更新的组件属性区域")
path: list[PathSegment] = Field(
min_length=1, description="区域内的字段路径,字符串为对象键,整数为数组下标"
)
value: JsonValue = Field(
description="替换该路径的值,支持任意 JSON;null 是赋值,不表示删除"
)