switch tab

This commit is contained in:
zhandouxiaojiji committed 2020-10-21 21:09:52 +08:00
1 parent 683eea771a
commit aefb646793
2 files changed
+13 -2

No files matched your search

+6 -1
View File
@@ -33,6 +33,10 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
this.ref = React.createRef(); this.ref = React.createRef();
} }
shouldComponentUpdate() {
return !this.graph;
}
componentDidMount() { componentDidMount() {
const graph = new TreeGraph({ const graph = new TreeGraph({
container: this.ref.current, container: this.ref.current,
@@ -206,7 +210,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
onSelectNode(node: string | INode) { onSelectNode(node: string | INode) {
const graph = this.graph; const graph = this.graph;
var curNode: INode; var curNode: INode;
if(typeof node == "string") { if (typeof node == "string") {
curNode = graph.findById(node) as INode; curNode = graph.findById(node) as INode;
} else { } else {
curNode = node; curNode = node;
@@ -223,6 +227,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
} }
render() { render() {
console.log("render editor")
const { curNode } = this.state; const { curNode } = this.state;
return ( return (
<div className="editor"> <div className="editor">
+7 -1
View File
@@ -245,7 +245,8 @@ export default class Main extends Component {
} }
render() { render() {
const { workspace, filepaths } = this.state; console.log("render main");
const { workspace, filepaths, curPath } = this.state;
document.title = `行为树编辑器 - ${workspace}`; document.title = `行为树编辑器 - ${workspace}`;
return ( return (
<Layout className="body"> <Layout className="body">
@@ -262,6 +263,11 @@ export default class Main extends Component {
hideAdd hideAdd
className="tabs" className="tabs"
type="editable-card" type="editable-card"
defaultActiveKey={curPath}
activeKey={curPath}
onChange={activeKey => {
this.setState({ curPath: activeKey })
}}
> >
{ {
filepaths.map(filepath => { filepaths.map(filepath => {