将 design_doc 的切分模块提升为目录模块
把 steps/separate.rs 提升为 steps/separate/mod.rs,只保留纯 State 变换 把 design_doc/cut_images.rs 移到 steps/separate/cut_images.rs,与它服务的切分步骤同层 把 normalize_cut_image_path 从 steps/mod.rs 下沉到 steps/separate/mod.rs,紧邻两个使用点 run_workflow.rs 改从 steps::separate 统一导入切分入口与登记入口 同步两份 UI 编辑器技术方案的模块布局与代码地图
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
mod checkpoint;
|
||||
mod creation;
|
||||
mod cut_images;
|
||||
mod run_workflow;
|
||||
mod steps;
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@ use super::checkpoint::{
|
||||
checkpoint_timestamp, CheckpointDocument, CheckpointLine, RoundOutcome, WorkflowLog,
|
||||
WorkflowRound,
|
||||
};
|
||||
use super::cut_images::register_cut_image_sprites;
|
||||
use super::steps::recognize::apply_recognition;
|
||||
use super::steps::separate::{add_sprite_assets, apply_separation};
|
||||
use super::steps::separate::{add_sprite_assets, apply_separation, register_cut_image_sprites};
|
||||
use crate::enforce_project_permission_policy;
|
||||
use crate::ui_editor::commands::separation::finalize_separation;
|
||||
use crate::ui_editor::commands::{
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
pub(crate) mod recognize;
|
||||
pub(crate) mod separate;
|
||||
|
||||
/// 镜像前端 `normalizeProjectRelativePath`:只做分隔符与根斜杠归一,不做路径校验。
|
||||
pub(crate) fn normalize_cut_image_path(path: &str) -> String {
|
||||
path.replace('\\', "/").trim_start_matches('/').to_string()
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,10 +1,11 @@
|
||||
//! 登记自动切分产出的图片并构造切分素材。镜像前端 `useUiEditorPage.ts` 的
|
||||
//! `import_local_project_image_assets` → `prepareSpriteAssetBatch` 两段。
|
||||
//! `separate` sub-step 的资源侧:登记自动切分产出的图片并构造切分素材。镜像前端
|
||||
//! `useUiEditorPage.ts` 的 `import_local_project_image_assets` →
|
||||
//! `prepareSpriteAssetBatch` 两段。
|
||||
//!
|
||||
//! 登记按路径复用已有 manifest 条目,所以重放不会重复登记;登记失败的路径只回报
|
||||
//! 说明,不回滚已经登记成功的资源。
|
||||
|
||||
use super::steps::normalize_cut_image_path;
|
||||
use super::normalize_cut_image_path;
|
||||
use crate::import_local_project_assets_for_agent;
|
||||
use crate::ui_editor::commands::SeparationDTO;
|
||||
use crate::ui_editor::resource::sprite::SpriteAsset;
|
||||
+17
-6
@@ -1,9 +1,15 @@
|
||||
//! 自动切分结果落到 State。镜像前端 `useUiEditorPage.ts` 的切分回填循环、
|
||||
//! `features/ui-editor/useUiEditorState.ts` 的 `addSpriteAssetsToState` 与
|
||||
//! `features/ui-editor/separationStatus.ts` 的问题状态写回。
|
||||
//! `separate` sub-step 的全部落地逻辑,按有无副作用分两个文件:
|
||||
//!
|
||||
//! 切分图片的登记不是这里的事:调用方先按 `bound_nodes` 的路径登记资源并构造
|
||||
//! `SpriteAsset`,本模块只做纯 State 变换。
|
||||
//! - `cut_images`:按 `bound_nodes` 的路径登记图片并构造 `SpriteAsset`,带项目
|
||||
//! manifest 副作用。
|
||||
//! - 本文件:登记结果与 `SeparationDTO` 到 State 的纯变换,镜像前端
|
||||
//! `useUiEditorPage.ts` 的切分回填循环、`features/ui-editor/useUiEditorState.ts`
|
||||
//! 的 `addSpriteAssetsToState` 与 `features/ui-editor/separationStatus.ts` 的问题
|
||||
//! 状态写回。
|
||||
|
||||
mod cut_images;
|
||||
|
||||
pub(crate) use cut_images::{register_cut_image_sprites, CutImageSprites};
|
||||
|
||||
use crate::ui_editor::commands::separation::{BoundNode, ProblematicNode};
|
||||
use crate::ui_editor::commands::SeparationDTO;
|
||||
@@ -14,6 +20,11 @@ use crate::ui_editor::state::State;
|
||||
use crate::ui_editor::utils::SpriteAssetId;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// 镜像前端 `normalizeProjectRelativePath`:只做分隔符与根斜杠归一,不做路径校验。
|
||||
pub(crate) fn normalize_cut_image_path(path: &str) -> String {
|
||||
path.replace('\\', "/").trim_start_matches('/').to_string()
|
||||
}
|
||||
|
||||
/// 把切分产出的素材合入 State。同一 id 已有不同内容时报错,镜像
|
||||
/// `addSpriteAssetsToState` 的 `duplicate` 与资源校验。
|
||||
pub(crate) fn add_sprite_assets(state: &State, sprites: &[SpriteAsset]) -> Result<State, String> {
|
||||
@@ -121,7 +132,7 @@ fn backfill_bound_node(
|
||||
sprite_by_path: &HashMap<String, SpriteAsset>,
|
||||
errors: &mut Vec<String>,
|
||||
) {
|
||||
let path = super::normalize_cut_image_path(&bound.cut_image_path);
|
||||
let path = normalize_cut_image_path(&bound.cut_image_path);
|
||||
let Some(sprite) = sprite_by_path.get(&path) else {
|
||||
errors.push(format!(
|
||||
"节点 {} 缺少已登记的自动切分素材图片:{path}",
|
||||
Reference in New Issue
Block a user