Files
my-v0-server/app/schemas/actions/update.py
T
2026-09-23 15:33:28 +08:00

23 lines
729 B
Python

"""精确更新组件 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 是赋值,不表示删除"
)