1
This commit is contained in:
@@ -3771,15 +3771,24 @@ fn apply_scene_asset_publish_result(profile: &mut JsonMap<String, JsonValue>, sc
|
||||
}
|
||||
|
||||
fn update_scene_chapter_acts_for_scene(profile: &mut JsonMap<String, JsonValue>, scene_id: &str, image_src: &str, generated_scene_asset_id: &str) {
|
||||
let Some(chapters) = profile.get_mut("sceneChapters").and_then(JsonValue::as_array_mut) else { return; };
|
||||
for chapter in chapters {
|
||||
let Some(chapter_object) = chapter.as_object_mut() else { continue; };
|
||||
if read_optional_text_field(chapter_object, &["sceneId"]).as_deref() != Some(scene_id) { continue; }
|
||||
let Some(acts) = chapter_object.get_mut("acts").and_then(JsonValue::as_array_mut) else { continue; };
|
||||
for act in acts {
|
||||
if let Some(act_object) = act.as_object_mut() {
|
||||
act_object.insert("backgroundImageSrc".to_string(), JsonValue::String(image_src.to_string()));
|
||||
act_object.insert("backgroundAssetId".to_string(), JsonValue::String(generated_scene_asset_id.to_string()));
|
||||
// 中文注释:当前结果页与发布链路以 sceneChapterBlueprints 为主,旧 sceneChapters 仅作兼容;同步场景资产时两边都要写,避免开局场景幕图只落在旧字段。
|
||||
for field in ["sceneChapterBlueprints", "sceneChapters"] {
|
||||
let Some(chapters) = profile.get_mut(field).and_then(JsonValue::as_array_mut) else { continue; };
|
||||
for chapter in chapters {
|
||||
let Some(chapter_object) = chapter.as_object_mut() else { continue; };
|
||||
let is_target_scene = read_optional_text_field(chapter_object, &["sceneId"]).as_deref() == Some(scene_id)
|
||||
|| chapter_object
|
||||
.get("linkedLandmarkIds")
|
||||
.and_then(JsonValue::as_array)
|
||||
.map(|ids| ids.iter().any(|id| id.as_str().map(str::trim) == Some(scene_id)))
|
||||
.unwrap_or(false);
|
||||
if !is_target_scene { continue; }
|
||||
let Some(acts) = chapter_object.get_mut("acts").and_then(JsonValue::as_array_mut) else { continue; };
|
||||
for act in acts {
|
||||
if let Some(act_object) = act.as_object_mut() {
|
||||
act_object.insert("backgroundImageSrc".to_string(), JsonValue::String(image_src.to_string()));
|
||||
act_object.insert("backgroundAssetId".to_string(), JsonValue::String(generated_scene_asset_id.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user