From 147e450d7702baf6a4e0dd59b210be9d3d69b22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 28 Feb 2020 23:21:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMIndex.js | 2 - .../src/modules/tpm/TPMRepositoryComponent.js | 16 +++--- .../tpm/shixunchild/Repository/Repository.js | 50 +++++++++++++------ .../Repository/RepositoryAddFile.js | 6 ++- .../RepositoryAddFileupload_file.js | 4 +- .../Repository/RepositoryCodeEditor.js | 10 ++-- .../shixunchild/Repository/Repositoryfile.js | 3 +- 7 files changed, 57 insertions(+), 34 deletions(-) diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index b4846e187..c40bf0a85 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -20,8 +20,6 @@ import TPMShixunDiscussContainer from './TPMShixunDiscussContainer'; import TPMRepositoryComponent from './TPMRepositoryComponent'; -import TPMRepositoryComponentdetails from './TPMRepositoryComponentdetails'; - import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits'; import TPMsettings from './TPMsettings/TPMsettings'; diff --git a/public/react/src/modules/tpm/TPMRepositoryComponent.js b/public/react/src/modules/tpm/TPMRepositoryComponent.js index aa5a35185..51ff6369b 100644 --- a/public/react/src/modules/tpm/TPMRepositoryComponent.js +++ b/public/react/src/modules/tpm/TPMRepositoryComponent.js @@ -76,7 +76,8 @@ class TPMRepositoryComponent extends Component { console.log(error) }); } - fetchCode = (newPathArray) => { + fetchCode = (newPathArray) =>{ + const path = newPathArray.join('/') // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/file_content.json @@ -137,7 +138,6 @@ class TPMRepositoryComponent extends Component { } // listItem 如果是num,则是通过面包屑点击过来的,取pathArray的子集 fetchRepo = (listItem) => { - // if(listItem === "main"||listItem){ // this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/repository`) // return; @@ -174,6 +174,7 @@ class TPMRepositoryComponent extends Component { listItemtypes:false }) } + // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json this.setState({ repositoryLoading: true, pathArray: newPathArray }) this.props.setpathArray(newPathArray) @@ -216,14 +217,14 @@ class TPMRepositoryComponent extends Component { ...response.data, repositoryLoading: false }); - this.props.history .replace(`/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}` + (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) + } // 初始化时,repo接口完毕后需要看是否需要fetchCode - if (fileInPathArray) { + if (fileInPathArray&&!type) { // this.fetchCode(newPathArray) } @@ -235,12 +236,11 @@ class TPMRepositoryComponent extends Component { }); } - oncodechanner=()=>{ - this.fetchRepo(0) + oncodechanner=(sum)=>{ + this.fetchRepo(sum) } render() { const { listItemtypes } = this.state; - return ( { listItemtypes===false? this.oncodechanner(sum)} > diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js index 2fe0987a8..943bf6f9e 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js @@ -40,8 +40,11 @@ class Repository extends Component { componentDidUpdate(prevProps, prevState) { if(prevProps!=this.props){ this.setState({ - trees:this.props.trees + trees:this.props.trees, + ischecke:false, + ischeckevalue:"" }) + } } onRepoFileClick = (item) => { @@ -61,7 +64,10 @@ class Repository extends Component { } onSelectDirectoryTree=(selectedKeys, info)=>{ - + this.setState({ + ischecke:false, + ischeckevalue:"" + }) this.onRepoFileClick(info.node.props.item) } @@ -73,7 +79,7 @@ class Repository extends Component { return }else{ confirm({ - title: '确认需要要删除该文件?', + title: '确认需要删除该文件?', okText: '确定', cancelText: '取消', onOk() { @@ -109,12 +115,18 @@ class Repository extends Component { } }) } - + let pathtype=path; if(path===undefined||path===""){ path=newfilspath }else{ path=path+"/"+newfilspath } + let gototype; + if(pathtype){ + gototype=1 + }else{ + gototype=2 + } const url = `/shixuns//${shixunId}/delete_git_file.json`; @@ -126,11 +138,23 @@ class Repository extends Component { .then((response) => { if(response.data.status == 0) { this.props.showNotification("删除成功") - this.state.trees.map((item,key)=>{ - if(item.name===newfilspath){ - this.state.trees.splice(key,1) - } - }) + if(gototype===1){ + if(this.state.trees.length>1){ + this.state.trees.map((item,key)=>{ + if(item.name===newfilspath){ + this.state.trees.splice(key,1) + } + }) + }else{ + this.props.fetchRepo(this.props.pathArray.length-1) + } + }else{ + this.state.trees.map((item,key)=>{ + if(item.name===newfilspath){ + this.state.trees.splice(key,1) + } + }) + } this.setState({ ischecke:false, ischeckevalue:"" @@ -138,10 +162,7 @@ class Repository extends Component { } }) .catch(function (error) { - this.setState({ - ischecke:false, - ischeckevalue:"" - }) + console.log(error) }); } onCheck = (checkedKeys, info) => { @@ -191,7 +212,6 @@ class Repository extends Component { {...this.props} Repositoryflag={Repositoryflag} hideNewFolder={()=>this.hideNewFolder()} - setfilepath={(path)=>this.setfilepath(path)} />:""} { repositoryLoading ?
:
@@ -393,7 +413,7 @@ class Repository extends Component { > { trees === undefined ?"": trees === null || trees.length===0?"":trees.map((item, index) => { return ( - :} id={`file${index}`} key={index}> + :} id={`file${index}`} key={index}>
x
)})} diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js index 45b96a6ed..74869120e 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js @@ -252,7 +252,7 @@ class RepositoryAddFile extends Component { }], })( - this.setinput(e)}/>提示:输入 / 可以将文件创建到新文件夹下 + this.setinput(e)}/>提示:输入 / 可以将文件创建到新文件夹下 )} @@ -289,7 +289,9 @@ class RepositoryAddFile extends Component {
- this.handleSubmit()}/> + this.handleSubmit()}/> + + {/* this.handleSubmit()}/>*/} ) } diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js index 82bdc12d4..8a0744479 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFileupload_file.js @@ -301,8 +301,8 @@ class RepositoryAddFileupload_files extends Component { - {/**/} - + + {/**/} ) diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js index 595557408..4685d86ce 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js @@ -91,7 +91,8 @@ class RepositoryCodeEditor extends Component { // }, 2000) } } - componentDidMount() { + componentDidMount(){ + let cmOptions = createCMOptions(this.props.mirror_name) const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0] , cmOptions); @@ -119,12 +120,13 @@ class RepositoryCodeEditor extends Component { ).then((response) => { if (response.data.content) { message.success('保存成功'); + this.setCohetepaperbool(this.props.pathArray.length===0?0:this.props.pathArray.length-1) this.setState({ codeSaving: false }) } }) } - setCohetepaperbool=()=>{ - this.props.oncodechanner() + setCohetepaperbool=(sum)=>{ + this.props.oncodechanner(sum) } render() { const { fileContent, shixunId, saveCode } = this.props; @@ -184,7 +186,7 @@ class RepositoryCodeEditor extends Component { this.setCohetepaperbool()} + setCohetepaperbool={() => this.setCohetepaperbool(this.props.pathArray.length===0?0:this.props.pathArray.length-1)} onSubmits={() => this.saveCode(this.extend_editor.getValue())}/>
diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js index 1653cbaaf..f1d83a71b 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js @@ -234,8 +234,10 @@ class Repositoryfile extends Component{ }).then((result)=>{ if(result){ if(result.data.status===0){ + this.props.fetchRepo(this.props.pathArray.length) this.props.showNotification("新建成功") this.props.hideNewFolder(); + } } }).catch((error)=>{ @@ -276,7 +278,6 @@ class Repositoryfile extends Component{
    - {console.log(main)} { main.length===0?"":main.map((item,key)=>{ return(