From aefb6467931896141850458cb4a59f2fc4805e97 Mon Sep 17 00:00:00 2001 From: zhandouxiaojiji Date: Wed, 21 Oct 2020 21:09:52 +0800 Subject: [PATCH] switch tab --- render-process/Editor/index.tsx | 7 ++++++- render-process/index.tsx | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/render-process/Editor/index.tsx b/render-process/Editor/index.tsx index 4a9d2bb..b98ce13 100644 --- a/render-process/Editor/index.tsx +++ b/render-process/Editor/index.tsx @@ -33,6 +33,10 @@ export default class Editor extends React.Component { this.ref = React.createRef(); } + shouldComponentUpdate() { + return !this.graph; + } + componentDidMount() { const graph = new TreeGraph({ container: this.ref.current, @@ -206,7 +210,7 @@ export default class Editor extends React.Component { onSelectNode(node: string | INode) { const graph = this.graph; var curNode: INode; - if(typeof node == "string") { + if (typeof node == "string") { curNode = graph.findById(node) as INode; } else { curNode = node; @@ -223,6 +227,7 @@ export default class Editor extends React.Component { } render() { + console.log("render editor") const { curNode } = this.state; return (
diff --git a/render-process/index.tsx b/render-process/index.tsx index de796da..b41e0f1 100644 --- a/render-process/index.tsx +++ b/render-process/index.tsx @@ -245,7 +245,8 @@ export default class Main extends Component { } render() { - const { workspace, filepaths } = this.state; + console.log("render main"); + const { workspace, filepaths, curPath } = this.state; document.title = `行为树编辑器 - ${workspace}`; return ( @@ -262,6 +263,11 @@ export default class Main extends Component { hideAdd className="tabs" type="editable-card" + defaultActiveKey={curPath} + activeKey={curPath} + onChange={activeKey => { + this.setState({ curPath: activeKey }) + }} > { filepaths.map(filepath => {