feat(flow): 新增分组执行与异步模式支持
refactor(executors): 将 Rhai 引擎评估逻辑迁移至 script_rhai 模块 docs: 添加 Flow 架构文档与示例 JSON feat(i18n): 新增前端多语言支持 perf(axios): 优化 token 刷新与 401 处理逻辑 style: 统一代码格式化与简化条件判断
This commit is contained in:
@ -88,6 +88,7 @@ impl From<FlowDSL> for super::domain::ChainDef {
|
||||
condition: e.condition,
|
||||
})
|
||||
.collect(),
|
||||
groups: std::collections::HashMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,13 +180,43 @@ fn build_chain_from_design(design: &DesignSyntax) -> anyhow::Result<super::domai
|
||||
use super::domain::{ChainDef, NodeDef, NodeId, NodeKind, LinkDef};
|
||||
|
||||
let mut nodes: Vec<NodeDef> = Vec::new();
|
||||
let mut groups: std::collections::HashMap<String, super::domain::GroupDef> = std::collections::HashMap::new();
|
||||
for n in &design.nodes {
|
||||
let kind = match n.kind.as_str() {
|
||||
"start" => NodeKind::Start,
|
||||
"end" => NodeKind::End,
|
||||
"condition" => NodeKind::Condition,
|
||||
"group" => NodeKind::Task, // group 本身不作为可执行节点,稍后跳过入 nodes
|
||||
_ => NodeKind::Task,
|
||||
};
|
||||
if n.kind.as_str() == "group" {
|
||||
// 解析分组:data.blockIDs(成员节点)、data.parentID(上层分组)、data.awaitPolicy(等待策略)
|
||||
let members: Vec<String> = n
|
||||
.data
|
||||
.get("blockIDs")
|
||||
.and_then(|v| v.as_array())
|
||||
.map(|arr| arr.iter().filter_map(|x| x.as_str().map(|s| s.to_string())).collect())
|
||||
.unwrap_or_default();
|
||||
let parent_id: Option<String> = n
|
||||
.data
|
||||
.get("parentID")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.to_string());
|
||||
let await_policy = match n
|
||||
.data
|
||||
.get("awaitPolicy")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("branch_exit")
|
||||
{
|
||||
"none" => super::domain::GroupAwaitPolicy::None,
|
||||
"node_leave" => super::domain::GroupAwaitPolicy::NodeLeave,
|
||||
"flow_end" => super::domain::GroupAwaitPolicy::FlowEnd,
|
||||
_ => super::domain::GroupAwaitPolicy::BranchExit,
|
||||
};
|
||||
groups.insert(n.id.clone(), super::domain::GroupDef { id: n.id.clone(), parent_id, members, await_policy });
|
||||
// group 节点不加入执行节点集合
|
||||
continue;
|
||||
}
|
||||
// 从节点 data.title 读取名称,若不存在则为空字符串
|
||||
let name = n.data.get("title").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
// 将可执行类型映射到任务标识(用于绑定任务实现)
|
||||
@ -268,7 +299,7 @@ fn build_chain_from_design(design: &DesignSyntax) -> anyhow::Result<super::domai
|
||||
links.push(LinkDef { from: NodeId(e.from.clone()), to: NodeId(e.to.clone()), condition: cond });
|
||||
}
|
||||
|
||||
Ok(ChainDef { name: design.name.clone(), nodes, links })
|
||||
Ok(ChainDef { name: design.name.clone(), nodes, links, groups })
|
||||
}
|
||||
|
||||
// Rewire external API to typed syntax -> validate -> build
|
||||
|
||||
Reference in New Issue
Block a user