|
|
|
@ -65,6 +65,7 @@ class CodeRepositoryView extends Component {
|
|
|
|
|
expandedKeys.push( index === 0 ? item : expandedKeys[index - 1] + '/' + item)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
expandedKeys.length = 1 // 没办法做到多级初始化
|
|
|
|
|
// 初始化时无法展开到根节点 https://github.com/fis-components/rc-tree/issues/3
|
|
|
|
|
expandedKeys.length && this.setState({
|
|
|
|
|
expandedKeys,
|
|
|
|
@ -110,10 +111,23 @@ class CodeRepositoryView extends Component {
|
|
|
|
|
// $('#codetab_con_1 .codemirrorBackground').hide()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
onTreeSelect = (selectedKeys, info) => {
|
|
|
|
|
if (!info.node.isLeaf()) {
|
|
|
|
|
const expandedKeys = this.state.expandedKeys.slice(0)
|
|
|
|
|
const _index = expandedKeys.indexOf(selectedKeys[0]);
|
|
|
|
|
if (_index == -1) {
|
|
|
|
|
expandedKeys.push(selectedKeys[0])
|
|
|
|
|
} else {
|
|
|
|
|
expandedKeys.splice( _index, 1)
|
|
|
|
|
}
|
|
|
|
|
this.setState({ expandedKeys })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.props.onTreeSelect(selectedKeys, info)
|
|
|
|
|
}
|
|
|
|
|
buildTree() {
|
|
|
|
|
// TODO http://localhost:3007/tasks/xgffnuomytpj 这个实训没有文件树
|
|
|
|
|
const { fileTreeData, onLoadData, onTreeSelect, fileTreeSelectedKeys } = this.props;
|
|
|
|
|
const { fileTreeData, onLoadData, fileTreeSelectedKeys } = this.props;
|
|
|
|
|
if (!fileTreeData || fileTreeData.length === 0) {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
@ -136,7 +150,7 @@ class CodeRepositoryView extends Component {
|
|
|
|
|
return (
|
|
|
|
|
<Tree
|
|
|
|
|
selectedKeys={fileTreeSelectedKeys}
|
|
|
|
|
onSelect={onTreeSelect}
|
|
|
|
|
onSelect={this.onTreeSelect}
|
|
|
|
|
onExpand={this.onExpand}
|
|
|
|
|
expandedKeys={this.state ? this.state.expandedKeys : []}
|
|
|
|
|
autoExpandParent={this.state.autoExpandParent}
|
|
|
|
|