support group by type for node def
This commit is contained in:
1 parent
be509bed9e
commit
543c5b09c3
7 files changed
+110
-88
No files matched your search
+17
-1
@@ -1,6 +1,7 @@
|
||||
import { TreeGraphData as G6TreeGraphData } from "@antv/g6";
|
||||
|
||||
export type NodeArgType = "string" | "int" | "float" | "boolean" | "enum" | "code";
|
||||
export type NodeType = "Action" | "Composite" | "Decorator" | "Condition" | "Other" | "Error";
|
||||
|
||||
export interface NodeArgOption {
|
||||
name: string;
|
||||
@@ -16,7 +17,7 @@ export interface NodeArg {
|
||||
}
|
||||
export interface NodeDef {
|
||||
name: string;
|
||||
type: string;
|
||||
type: NodeType;
|
||||
desc?: string;
|
||||
args?: NodeArg[];
|
||||
input?: string[];
|
||||
@@ -67,3 +68,18 @@ export const unknownNodeDef: NodeDef = {
|
||||
desc: "新建节点",
|
||||
type: "Action",
|
||||
};
|
||||
|
||||
export const getNodeType = (def: NodeDef): NodeType => {
|
||||
const type = def.type.toLocaleLowerCase().toString();
|
||||
if (type.startsWith("action")) {
|
||||
return "Action";
|
||||
} else if (type.startsWith("composite")) {
|
||||
return "Composite";
|
||||
} else if (type.startsWith("decorator")) {
|
||||
return "Decorator";
|
||||
} else if (type.startsWith("condition")) {
|
||||
return "Condition";
|
||||
} else {
|
||||
return "Other";
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user