补齐快速编辑重绘契约
Project CI / Repository checks (pull_request) Successful in 1m8s
Project CI / Frontend tests (pull_request) Successful in 3m17s
Project CI / Backend tests (pull_request) Successful in 3m57s
Project CI / Native shell tests (pull_request) Failing after 10m8s

恢复快速编辑面板的模式与重绘产物状态字段

补回快速编辑结果图层工厂
This commit is contained in:
2026-08-12 18:01:19 +08:00
parent 99fb292e7d
commit 2aeb977458
2 changed files with 73 additions and 0 deletions
@@ -265,6 +265,7 @@ export type GenerateDialogState = {
assetLabel?: string;
status: 'idle' | 'generating' | 'pending-confirmation' | 'failed';
composerOpen?: boolean;
isRedrawAsNewArtifact?: boolean;
sourceLayerId?: string;
generatedLayerId?: string;
specType?: SpecGenerationType;
@@ -444,6 +445,7 @@ export type CanvasContextMenuState =
export type QuickEditPanelState = {
referenceUploadContextId?: string;
mode?: 'quick-edit' | 'redraw';
sourceLayerId: string;
prompt: string;
assetLabel?: string;
@@ -32,6 +32,16 @@ type GeneratedResultLayerOptions = {
generationInputs?: CanvasGenerationInputs;
};
type QuickEditResultLayerOptions = {
generated: EditorImageGenerationResult;
generatedIndex: number;
sourceLayer: CanvasLayer;
generationInputs: CanvasGenerationInputs;
mode?: 'quick-edit' | 'redraw';
frame?: GenerateDialogState['placeholder'];
title?: string;
};
type IconSpritesheetResultLayerOptions = {
generated: EditorIconSpritesheetGenerationResult;
iconResults?: EditorIconSpritesheetIconResult[] | null;
@@ -173,6 +183,67 @@ export function createGeneratedResultLayer({
);
}
export function createQuickEditResultLayer({
generated,
generatedIndex,
sourceLayer,
generationInputs,
mode = 'quick-edit',
frame,
title,
}: QuickEditResultLayerOptions): CanvasLayer {
const originalWidth =
frame?.originalWidth ||
generated.width ||
sourceLayer.originalWidth ||
1024;
const originalHeight =
frame?.originalHeight ||
generated.height ||
sourceLayer.originalHeight ||
1024;
const { width, height } = resolveLayerResolutionSize(
originalWidth,
originalHeight,
{
width: sourceLayer.width,
height: sourceLayer.height,
},
);
const frameX =
frame && frame.width > 0
? frame.x + frame.width / 2 - width / 2
: undefined;
const frameY =
frame && frame.height > 0
? frame.y + frame.height / 2 - height / 2
: undefined;
return applyGeneratedMetadata(
{
id: `layer-quick-edit-${generatedIndex}`,
resourceId: `local-resource-quick-edit-${generatedIndex}`,
title:
title ??
`${sourceLayer.title} ${mode === 'redraw' ? '重绘' : '快速编辑'}`,
src: generated.imageSrc,
x: frameX ?? sourceLayer.x + sourceLayer.width + 32,
y: frameY ?? sourceLayer.y,
width,
height,
originalWidth,
originalHeight,
zIndex: generatedIndex + 10,
sourceType: generated.sourceType,
sourceResourceId: sourceLayer.resourceId,
groupId: sourceLayer.groupId,
assetKind: sourceLayer.assetKind,
},
generated,
generationInputs,
);
}
export function applyImageEditResultToSourceLayer({
generated,
sourceLayer,