fix:处理模型错误添加大量文本的bug

This commit is contained in:
2026-10-14 01:08:50 -07:00
parent a80727b7a0
commit 41b769adde
35 changed files with 388 additions and 149 deletions
+13
View File
@@ -106,6 +106,15 @@ class MaterialField(ExtensibleModel):
default=False,
description="颜色跟随画布主题:默认配置里不写值,由前端按画布主题(亮 / 暗)取色;写入 null 恢复跟随",
)
example: Literal["data", "label"] | None = Field(
default=None,
description="默认配置里的值是演示内容,不是结构默认值:data 是示例数据(图表数据、指标值),"
"label 是示例文字(标题、系列名)。新增组件沿用了它们时告诉 agent;沿用示例数据的组件交付时标为示例数据",
)
identifies: bool = Field(
default=False,
description="这个字段的文字是组件在画面上的名字或内容(图表标题、指标名、文本),大屏摘要用它帮助认出用户说的组件",
)
editable: bool = Field(default=True, description="是否允许修改")
panel: bool = Field(default=True, description="是否显示在前端属性面板")
span: int | None = Field(default=None, description="属性面板栅格宽度,24 为整行")
@@ -122,6 +131,10 @@ class MaterialField(ExtensibleModel):
raise ValueError(f"{self.value_type} 字段没有属性面板控件,panel 必须为 false: {self.path}")
if self.themed and (self.value_type != "color" or self.default is not None):
raise ValueError(f"只有 color 字段可以跟随主题,且不能声明 default: {self.path}")
if self.example and (self.themed or self.default is not None):
raise ValueError(f"示例内容要写在默认配置里,不能跟随主题或声明 default: {self.path}")
if self.identifies and self.value_type != "string":
raise ValueError(f"只有 string 字段可以用来识别组件: {self.path}")
return self
def value_error(self, value: JsonValue) -> str | None: