From 9f58eb1a5af8fb0a02739e760537303db2d47bb3 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sat, 7 May 2022 14:38:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=AF=B7=E6=B1=82=E9=9C=80?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E4=B8=A4=E6=AC=A1=E8=8E=B7=E5=8F=96=E5=88=86?= =?UTF-8?q?=E6=94=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 2 +- src/forge/Merge/CreateMerge.js | 44 +++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index cd3aca3d..b4107e46 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -25,7 +25,7 @@ if (isDev) { } debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : - window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' } window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/src/forge/Merge/CreateMerge.js b/src/forge/Merge/CreateMerge.js index e4ac51d4..ec8d14de 100644 --- a/src/forge/Merge/CreateMerge.js +++ b/src/forge/Merge/CreateMerge.js @@ -99,6 +99,7 @@ class CreateMerge extends Component { // 再调用比较接口 const branchParams = getBranchParams(this.props.location.pathname); this.getMergeInfo(branchParams,true); + this.checkBranch(branchParams); }; componentDidUpdate = (preProps) => { @@ -108,6 +109,7 @@ class CreateMerge extends Component { if (oldPathname !== newPathname) { const branchParams = getBranchParams(newPathname); this.getMergeInfo(branchParams); + this.checkBranch(branchParams); } }; @@ -134,10 +136,9 @@ class CreateMerge extends Component { merge: returnbar(mergeBranch), pull: returnbar(pullBranch), }); - this.checkBranch(branchParams); - this.setState({ - isSpin: false,isCompareSpin: false - }); + // this.setState({ + // isSpin: false,isCompareSpin: false + // }); } }) .catch((error) => { @@ -148,10 +149,14 @@ class CreateMerge extends Component { checkBranch=async(branchParams)=>{ const { mergeBranch , mergeOwner, projectId , pullBranch ,pullOwner} = branchParams; - let getbranch =await this.getBranchList(mergeOwner,projectId,pullBranch,mergeBranch); - // let checkpull =await this.getBranchList(pullOwner,projectId,pullBranch,"pull"); - if(getbranch){ + let getbranch =await this.getBranchList(mergeOwner,projectId,pullBranch,mergeBranch,"merge"); + let checkpull =await this.getBranchList(pullOwner,projectId,pullBranch,mergeBranch,"pull"); + if(getbranch && checkpull){ this.compareProject(mergeOwner === pullOwner, branchParams); + }else{ + this.setState({ + isSpin: false,isCompareSpin: false + }); } } @@ -180,13 +185,9 @@ class CreateMerge extends Component { } this.setState({ comparesData: result.data, + isSpin: false,isCompareSpin: false }); } - this.setState({ - isFirstLoading: false, - isSpin: false, - isCompareSpin: false, - }); }) .catch((error) => { this.setState({ isSpin: false, isCompareSpin: false }); @@ -194,13 +195,22 @@ class CreateMerge extends Component { }; // 根据所有者、仓库名,获取分支列表,目前仅涉及目标仓库分支查询 - getBranchList =async(owner,identifier,branch,mergebranch) => { + getBranchList =async(owner,identifier,branch,mergebranch,type) => { const url = `/${owner}/${identifier}/branches.json`; let check = await axios.get(url).then((result) => { if(result.data){ let pfilter = (result.data || []).filter(i => i.name === branch).length === 0; let mfilter = (result.data || []).filter(i => i.name === mergebranch).length === 0; - if(pfilter){ + if(type === "pull"){ + this.setState({ + pullBranches:result.data, + }) + }else{ + this.setState({ + mergeBranches:result.data + }) + } + if(type === "pull" && pfilter){ this.setState({ showMessage: branch, defaultMessage: `源分支不存在`, @@ -208,7 +218,7 @@ class CreateMerge extends Component { }); return false; } - if(mfilter){ + if(type === "merge" && mfilter){ this.setState({ showMessage: mergebranch, defaultMessage: `目标分支不存在`, @@ -216,10 +226,6 @@ class CreateMerge extends Component { }); return false; } - this.setState({ - pullBranches:result.data, - mergeBranches:result.data - }) return true; } })