feat:新增物料
This commit is contained in:
@@ -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))
|
||||
# 校验合并后的画布属性,尺寸等字段不合法时直接抛出异常
|
||||
|
||||
Reference in New Issue
Block a user