From c951ed736f942a80e517f5fc0d7eb77eaf932d8a Mon Sep 17 00:00:00 2001 From: suzmii Date: Wed, 5 Aug 2026 11:12:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E5=8F=A3=E5=9B=BE=E7=89=87=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E7=94=9F=E6=88=90=E6=A8=A1=E5=BC=8F=E4=B8=8E=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用类型完备的 Record 集中维护生成模式与画布工具映射 保留未知运行时模式默认回落到普通图片生成工具的历史行为 --- .../useImageCanvasGenerationWorkflow.ts | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/components/image-editor/useImageCanvasGenerationWorkflow.ts b/src/components/image-editor/useImageCanvasGenerationWorkflow.ts index e0e7fb364..dbd68a7f4 100644 --- a/src/components/image-editor/useImageCanvasGenerationWorkflow.ts +++ b/src/components/image-editor/useImageCanvasGenerationWorkflow.ts @@ -316,34 +316,25 @@ function findSourceAnimationLayer( ); } +const CANVAS_TOOL_BY_GENERATION_MODE = { + generate: 'generate', + spec: 'spec', + character: 'character', + icon: 'icon', + publication: 'publication', + 'ui-design': 'ui-design', + 'quick-edit': 'generate', + 'character-animation': 'character', + video: 'video', + 'audio-sound-effect': 'music', + 'audio-background-music': 'music', + scene: 'scene', +} as const satisfies Record; + function getCanvasToolForGenerationMode( mode: CanvasGenerationDialogState['mode'], ): CanvasTool { - if (mode === 'video') { - return 'video'; - } - if (mode === 'scene') { - return 'scene'; - } - if (mode === 'audio-sound-effect' || mode === 'audio-background-music') { - return 'music'; - } - if (mode === 'character' || mode === 'character-animation') { - return 'character'; - } - if (mode === 'icon') { - return 'icon'; - } - if (mode === 'publication') { - return 'publication'; - } - if (mode === 'ui-design') { - return 'ui-design'; - } - if (mode === 'spec') { - return 'spec'; - } - return 'generate'; + return CANVAS_TOOL_BY_GENERATION_MODE[mode] ?? 'generate'; } const LAST_CHARACTER_SPEC_REFERENCE_CACHE_KEY =