feat:对接中心平台,完善接口鉴权

This commit is contained in:
2026-10-01 04:01:44 -07:00
parent 8e37d30ef2
commit 618290d852
20 changed files with 391 additions and 70 deletions
+14
View File
@@ -3,6 +3,7 @@
from copy import deepcopy
from app.actions.base import BaseActionHandler
from app.resources.material_fields import editable_fields, known_prop_keys
from app.schemas.actions import UpdateAction
from app.schemas.screen import Screen
@@ -16,6 +17,19 @@ class UpdateHandler(BaseActionHandler[UpdateAction]):
if action.section == "style" and target.style is None:
target.style = {}
# props 第一层不能新造字段:渲染器不会读取约定外的字段,新造只会“成功”却没有效果
if action.section == "props":
known = known_prop_keys(target)
if known is not None and action.path[0] not in known:
labels = "、".join(
f"{field['label']}={field['section']}.{field['path']}"
for field in editable_fields(target.type)
)
raise ValueError(
f"组件 {target.type} 的 props 没有字段 {action.path[0]!r},"
f"不能新造组件级属性;可编辑字段:{labels or '无'}"
)
# 获取动作指定的属性区域,作为路径遍历的起点
current = getattr(target, action.section)
# 逐段访问路径,只有到达末级时才写入新值