feat:新增物料

This commit is contained in:
2026-10-13 04:16:00 -07:00
parent b117f21e3a
commit a80727b7a0
15 changed files with 174 additions and 54 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ from app.schemas.screen import Canvas, Screen
class UpdateCanvasHandler(BaseActionHandler[UpdateCanvasAction]):
def apply(self, screen: Screen, action: UpdateCanvasAction) -> Screen:
# 将现有画布转成字典,保留动作没有指定的字段
properties = screen.canvas.model_dump()
# 将现有画布转成字典,保留动作没有指定的字段;没写过的主题、背景色不补成 null
properties = screen.canvas.model_dump(exclude_unset=True)
# 顶层字段整体替换,嵌套对象不做深度合并
properties.update(deepcopy(action.properties))
# 校验合并后的画布属性,尺寸等字段不合法时直接抛出异常