1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

add search module

This commit is contained in:
shanshuirenjia
2018-12-13 20:42:51 +08:00
parent a74ada65d4
commit eb349bd2ff
6 changed files with 89 additions and 25 deletions

View File

@@ -283,13 +283,26 @@ class Wiki extends Component {
}
onSearchedClick = (item) => {
//just for file
let path = item.path;
if (this.state.currentFilePath !== path) {
let tree = this.state.treeData.clone();
let node = tree.getNodeByPath(path);
tree.expandNode(node);
this.showFile(node.path);
if (item.is_dir) {
let path = item.path.slice(0, item.path.length - 1);
if (this.state.currentFilePath !== path) {
let tree = this.state.treeData.clone();
let node = tree.getNodeByPath(path);
tree.expandNode(node);
this.showDir(node.path);
}
} else if (Utils.isMarkdownFile(item.path)) {
let path = item.path;
if (this.state.currentFilePath !== path) {
let tree = this.state.treeData.clone();
let node = tree.getNodeByPath(path);
tree.expandNode(node);
this.showFile(node.path);
}
} else {
let url = siteRoot + 'lib/' + item.repo_id + '/file' + item.path;
let newWindow = window.open('about:blank');
newWindow.location.href = url;
}
}