feat: support enum args and default value

This commit is contained in:
duanhongbo committed 2020-12-03 11:24:10 +08:00
1 parent 639a661a9a
commit fd03d3ff66
2 files changed
+10

No files matched your search

+1
View File
@@ -4,6 +4,7 @@ export interface ArgsDefType {
name: string; name: string;
type: string; type: string;
desc: string; desc: string;
default: string;
} }
export interface BehaviorNodeTypeModel { export interface BehaviorNodeTypeModel {
name: string; name: string;
+9
View File
@@ -22,6 +22,7 @@ import { FormInstance } from "antd/lib/form";
import Markdown from "react-markdown"; import Markdown from "react-markdown";
const { Item } = Form; const { Item } = Form;
const { Option } = Select;
interface NodePanelProps { interface NodePanelProps {
model: BehaviorNodeModel; model: BehaviorNodeModel;
@@ -212,6 +213,13 @@ export default class NodePanel extends React.Component<NodePanelProps> {
return <Switch onChange={this.handleSubmit} />; return <Switch onChange={this.handleSubmit} />;
} else if (e.type.indexOf("lua") >= 0) { } else if (e.type.indexOf("lua") >= 0) {
return <Input onBlur={this.handleSubmit} placeholder={"公式"} />; return <Input onBlur={this.handleSubmit} placeholder={"公式"} />;
} else if (e.type.indexOf("enum") >= 0) {
const list = e.type.substring(e.type.indexOf("|")+1).split(',')
return <Select style={{ width: 120 }} onChange={this.handleSubmit} >
{list.map((e)=>{
return (<Option key={e} value={e}>{e}</Option>)
})}
</Select>;
} }
}; };
@@ -235,6 +243,7 @@ export default class NodePanel extends React.Component<NodePanelProps> {
const required = e.type.indexOf("?") == -1; const required = e.type.indexOf("?") == -1;
return ( return (
<Item <Item
initialValue={e.default}
name={`args.${e.name}`} name={`args.${e.name}`}
label={e.desc} label={e.desc}
key={`args.${e.name}`} key={`args.${e.name}`}