feat: 收口 Rust Web 3000 主链
This commit is contained in:
@@ -5459,23 +5459,22 @@ fn mindmap_tree_candidate(data: &Value) -> Value {
|
||||
let Some(map) = candidate.as_object() else {
|
||||
return candidate;
|
||||
};
|
||||
let next = if (map.contains_key("ok") || map.contains_key("meta"))
|
||||
&& map.get("data").is_some()
|
||||
{
|
||||
map.get("data").cloned()
|
||||
} else if map
|
||||
.get("data")
|
||||
.map(|value| value.get("data").is_some() || value.get("children").is_some())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
map.get("data").cloned()
|
||||
} else if let Some(nested) = map.get("mindmap") {
|
||||
Some(nested.clone())
|
||||
} else if let Some(nested) = map.get("result") {
|
||||
Some(nested.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let next =
|
||||
if (map.contains_key("ok") || map.contains_key("meta")) && map.get("data").is_some() {
|
||||
map.get("data").cloned()
|
||||
} else if map
|
||||
.get("data")
|
||||
.map(|value| value.get("data").is_some() || value.get("children").is_some())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
map.get("data").cloned()
|
||||
} else if let Some(nested) = map.get("mindmap") {
|
||||
Some(nested.clone())
|
||||
} else if let Some(nested) = map.get("result") {
|
||||
Some(nested.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let Some(next) = next else {
|
||||
return candidate;
|
||||
};
|
||||
@@ -6570,7 +6569,10 @@ fn merge_json_object(base: &mut Value, patch: &Value) {
|
||||
}
|
||||
|
||||
fn set_json_path(root: &mut Value, path: &str, value: Value) -> bool {
|
||||
let segments: Vec<&str> = path.split('.').filter(|segment| !segment.is_empty()).collect();
|
||||
let segments: Vec<&str> = path
|
||||
.split('.')
|
||||
.filter(|segment| !segment.is_empty())
|
||||
.collect();
|
||||
if segments.is_empty() {
|
||||
return false;
|
||||
}
|
||||
@@ -6582,7 +6584,9 @@ fn set_json_path(root: &mut Value, path: &str, value: Value) -> bool {
|
||||
let Some(map) = current.as_object_mut() else {
|
||||
return false;
|
||||
};
|
||||
current = map.entry((*segment).to_string()).or_insert_with(|| json!({}));
|
||||
current = map
|
||||
.entry((*segment).to_string())
|
||||
.or_insert_with(|| json!({}));
|
||||
}
|
||||
if !current.is_object() {
|
||||
*current = json!({});
|
||||
@@ -6599,7 +6603,10 @@ fn apply_mindmap_compat_payload_patch(
|
||||
metadata: &mut BTreeMap<String, Value>,
|
||||
command: &Value,
|
||||
) -> bool {
|
||||
let path = command.get("path").and_then(Value::as_str).unwrap_or_default();
|
||||
let path = command
|
||||
.get("path")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default();
|
||||
if path.trim().is_empty() {
|
||||
return false;
|
||||
}
|
||||
@@ -11490,7 +11497,10 @@ mod tests {
|
||||
assert_eq!(result.applied, 2);
|
||||
assert!(result.errors.is_empty());
|
||||
assert_eq!(result.data["data"]["data"]["text"], json!("KMIND"));
|
||||
assert_eq!(result.data["data"]["data"]["generalization"]["text"], json!("概要"));
|
||||
assert_eq!(
|
||||
result.data["data"]["data"]["generalization"]["text"],
|
||||
json!("概要")
|
||||
);
|
||||
assert_eq!(result.data["view"]["state"]["scale"], json!(1.2));
|
||||
assert_eq!(result.data["view"]["state"]["x"], json!(10));
|
||||
assert_eq!(result.data["view"]["transform"]["scaleX"], json!(1.2));
|
||||
|
||||
Reference in New Issue
Block a user