Add UI-design asset extraction & spritesheet support
Introduce a new UI design asset extraction flow: add POST /api/editor/ui-designs/assets/extractions handler that always uses gpt-image-2 with the fixed prompt "提取画面中的所有独立并整理成spritesheet"; parse Data URL references, call OpenAI image edits, return a spritesheet and sliced icon assets. Increase request body limit for image Data URLs and wire the route with bearer auth. Add platform-image slicing: slice_generated_icon_spritesheet_all_by_connected_components (with auto-naming "素材 1..N", foreground estimation and heuristics) and export it. Add Rust tests for the handler, prompt constant, and slicing behavior. Update frontend client and integration tests to call the new extractEditorUiDesignAssets API and verify spritesheet + icon layers are added to the canvas and persisted. Update multiple docs to describe the extraction UI, toolbar placement, and related audio/playback pitfalls. Minor related updates: toolbar button ordering and audio duration / signed read-url notes.
This commit is contained in:
@@ -66,6 +66,8 @@ export const DEFAULT_ICON_DESCRIPTIONS = [
|
||||
'原图按钮',
|
||||
'冻结按钮',
|
||||
];
|
||||
export const UI_DESIGN_ASSET_EXTRACTION_PROMPT =
|
||||
'提取画面中的所有独立并整理成spritesheet';
|
||||
export const QUICK_EDIT_SIZE_PRESETS = [
|
||||
'1024x1024',
|
||||
'1536x1024',
|
||||
@@ -266,6 +268,9 @@ export function getLayerKindLabel(layer: CanvasLayer) {
|
||||
if (layer.assetKind === 'icon') {
|
||||
return '图标';
|
||||
}
|
||||
if (layer.assetKind === 'icon-spritesheet') {
|
||||
return '图集';
|
||||
}
|
||||
if (layer.assetKind === 'icon-spec') {
|
||||
return '图标规范';
|
||||
}
|
||||
@@ -316,6 +321,9 @@ export function formatLayerImageType(layer: CanvasLayer) {
|
||||
if (layer.assetKind === 'icon') {
|
||||
return '图标素材图片';
|
||||
}
|
||||
if (layer.assetKind === 'icon-spritesheet') {
|
||||
return '图标素材图集';
|
||||
}
|
||||
if (layer.assetKind === 'icon-spec') {
|
||||
return '图标规范图片';
|
||||
}
|
||||
@@ -578,6 +586,24 @@ export function buildIconGenerationInputs(
|
||||
};
|
||||
}
|
||||
|
||||
export function buildUiDesignAssetExtractionGenerationInputs(
|
||||
sourceLayer: CanvasLayer,
|
||||
): CanvasGenerationInputs {
|
||||
return {
|
||||
fields: createGenerationInputField(
|
||||
'提取提示词',
|
||||
UI_DESIGN_ASSET_EXTRACTION_PROMPT,
|
||||
),
|
||||
references: [
|
||||
{
|
||||
title: 'UI设计图',
|
||||
label: sourceLayer.title,
|
||||
src: sourceLayer.objectKey?.trim() || sourceLayer.src,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function buildEditGenerationInputs(
|
||||
title: '修改要求' | '快速编辑提示词' | '重绘提示词',
|
||||
prompt: string,
|
||||
|
||||
Reference in New Issue
Block a user