fix Properties update

This commit is contained in:
zhandouxiaojiji committed 2020-11-25 16:52:22 +08:00
1 parent 8177424594
commit 31b3b7404f
2 files changed
+40 -33

No files matched your search

+1 -4
View File
@@ -39,7 +39,7 @@ interface BehaviorNodeTypeModel {
```shell ```shell
npm install # 安装依赖 npm install # 安装依赖
npm start # 运行测试 npm start # 运行测试
npm run build # 编译exe可执行文件 npm run dist # 编译exe可执行文件
``` ```
## 技术栈 ## 技术栈
@@ -53,12 +53,9 @@ npm run build # 编译exe可执行文件
+ js/ts版本 计划中。 + js/ts版本 计划中。
## TODO ## TODO
+ 复制粘贴功能(跨工作区)
+ 历史记录(撤销/恢复) + 历史记录(撤销/恢复)
+ 资源面板支持树型结构 + 资源面板支持树型结构
+ 快捷键功能
+ 右键菜单 + 右键菜单
+ 联调功能
## About ## About
目前编辑器还处于非常简陋的阶段,有问题可以联系作者(QQ1013299930),本项目将长期维护,望前端大佬们多提点~ 目前编辑器还处于非常简陋的阶段,有问题可以联系作者(QQ1013299930),本项目将长期维护,望前端大佬们多提点~
+39 -29
View File
@@ -131,7 +131,7 @@ class FileDataNode implements DataNode {
interface PropertiesState { interface PropertiesState {
root: FileDataNode; root: FileDataNode;
searchKey: string; searchKey: string;
defaultExpandedKeys:string[]; defaultExpandedKeys: string[];
expandedKeys: string[]; expandedKeys: string[];
autoExpandParent: boolean; autoExpandParent: boolean;
rightClickNode: { rightClickNode: {
@@ -155,7 +155,7 @@ export default class Properties extends Component<PropertiesProps> {
searchKey: "", searchKey: "",
rightClickNode: null, rightClickNode: null,
expandedKeys: [], expandedKeys: [],
defaultExpandedKeys:[], defaultExpandedKeys: [],
autoExpandParent: true, autoExpandParent: true,
}; };
@@ -175,15 +175,25 @@ export default class Properties extends Component<PropertiesProps> {
this.forceUpdate(); this.forceUpdate();
}); });
ipcRenderer.on(MainEventType.OPEN_DIR, (event: any, workdir: any, workspace: string) => {
console.log("prop on open workspace", workspace);
this.updateRoot();
this.forceUpdate();
});
this.updateRoot();
}
updateRoot() {
var workdir = this.props.workdir; var workdir = this.props.workdir;
if (!workdir || workdir === "") { if (!workdir || workdir === "") {
return; return;
} }
const root = this.getRootNode(workdir); const root = this.getRootNode(workdir);
root.expandSelf(); root.expandSelf();
this.setState({ this.setState({
root: root , root: root,
expandedKeys : [root.key], expandedKeys: [root.key],
defaultExpandedKeys: [root.key] defaultExpandedKeys: [root.key]
}); });
} }
@@ -222,7 +232,7 @@ export default class Properties extends Component<PropertiesProps> {
const expandedKeys = this.state.root const expandedKeys = this.state.root
.getList() .getList()
.map((item) => { .map((item) => {
if(!item.isLeaf) if (!item.isLeaf)
return null; return null;
const title = item.title as string; const title = item.title as string;
if (title.includes(value) && item.parent) { if (title.includes(value) && item.parent) {
@@ -231,7 +241,7 @@ export default class Properties extends Component<PropertiesProps> {
return null; return null;
}) })
.filter((item, i, self) => item && self.indexOf(item) === i); .filter((item, i, self) => item && self.indexOf(item) === i);
if (value && value.length>0) { if (value && value.length > 0) {
this.setState({ this.setState({
searchKey: value, searchKey: value,
expandedKeys: expandedKeys, expandedKeys: expandedKeys,
@@ -255,7 +265,7 @@ export default class Properties extends Component<PropertiesProps> {
return nodeKey.includes(searchKey); return nodeKey.includes(searchKey);
} }
titleRender(node:DataNode):React.ReactNode{ titleRender(node: DataNode): React.ReactNode {
const titleStr = node.title as string; const titleStr = node.title as string;
const searchKey = this.state.searchKey; const searchKey = this.state.searchKey;
const index = titleStr.indexOf(searchKey); const index = titleStr.indexOf(searchKey);
@@ -265,30 +275,30 @@ export default class Properties extends Component<PropertiesProps> {
//return (<span>{titleStr}</span>) //return (<span>{titleStr}</span>)
return index > -1 ? ( return index > -1 ? (
<span> <span>
{beforeStr} {beforeStr}
<span className="site-tree-search-value">{searchKey}</span> <span className="site-tree-search-value">{searchKey}</span>
{afterStr} {afterStr}
</span> </span>
) : ( ) : (
<span>{titleStr}</span> <span>{titleStr}</span>
); );
} }
handleOnLoadData(loadNode:EventDataNode) { handleOnLoadData(loadNode: EventDataNode) {
return new Promise((resolve) => { return new Promise((resolve) => {
const root = this.state.root; const root = this.state.root;
const node = root.findChild(loadNode.key as string); const node = root.findChild(loadNode.key as string);
if (node) { if (node) {
node.expandSelf(); node.expandSelf();
this.setState({ root: root }); this.setState({ root: root });
this.forceUpdate(); this.forceUpdate();
} }
resolve(); resolve();
return; return;
}); });
} }
render() { render() {
console.log("render Properties"); console.log("render Properties");
@@ -322,8 +332,8 @@ export default class Properties extends Component<PropertiesProps> {
onExpand={(keys, info) => { onExpand={(keys, info) => {
console.log("onExpand", info); console.log("onExpand", info);
this.setState({ this.setState({
expandedKeys:keys, expandedKeys: keys,
autoExpandParent:false autoExpandParent: false
}) })
// if (info.expanded && !info.node.expanded) { // if (info.expanded && !info.node.expanded) {
// //let newRoot = _.cloneDeep(root); // //let newRoot = _.cloneDeep(root);
@@ -339,7 +349,7 @@ export default class Properties extends Component<PropertiesProps> {
></DirectoryTree> ></DirectoryTree>
</div> </div>
) : ( ) : (
`Work Dir (${workdir}) Empty` `Work Dir (${workdir}) Empty`
); );
} }
} }