Add UI-specific prompt rendering for design assets in resource references

This commit is contained in:
2026-09-14 18:30:28 +08:00
parent 279a5e8e0e
commit 470e85c0ff
@@ -133,6 +133,23 @@ fn validate_resource_reference_id(value: &str) -> Result<String, String> {
Ok(resource_id.to_string())
}
/// Render the prompt context for a UI design asset.
///
/// Keep this separate from the generic resource renderer so UI-specific
/// instructions/metadata can evolve without changing other asset kinds.
fn render_ui_design_reference_line(
asset: &GameCreationAppAssetManifestEntry,
resource_id: &str,
label: &str,
local_path: &str,
source: &str,
) -> String {
format!(
"- 素材 ID{resource_id};名称:{label};类型:{};媒体类型:{};项目路径:{local_path};来源:{source}",
asset.kind, asset.media_type
)
}
fn render_resource_reference_line(
manifest: &GameCreationAppManifest,
reference: &DirectCodexResourceReference,
@@ -149,6 +166,19 @@ fn render_resource_reference_line(
.unwrap_or_else(|| asset_display_label(asset));
let source = sanitize_reference_source(reference.source.as_deref())
.unwrap_or_else(|| "unknown".to_string());
let is_ui_design = matches!(
asset.kind.to_ascii_lowercase().as_str(),
"ui" | "ui-design" | "ui-prototype"
);
if is_ui_design {
return Ok(render_ui_design_reference_line(
asset,
&resource_id,
&label,
&local_path,
&source,
));
}
Ok(format!(
"- 素材 ID{resource_id};名称:{label};类型:{};媒体类型:{};项目路径:{local_path};来源:{source}",
asset.kind, asset.media_type