From bba939094c6f9097bab5e9135b30ba2cc7512e3d Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 22 Oct 2020 19:34:11 +0800 Subject: [PATCH] =?UTF-8?q?educoder=20=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/UrlTool.js | 12 ++--- src/forge/Main/CoderRootDirectory.js | 75 +++++++++++++++----------- src/forge/Main/Detail.js | 78 +++++++++++++++++++--------- src/forge/Main/DetailTop.js | 60 +++++++++++++++------ src/forge/Main/IndexItem.js | 13 +++-- src/forge/Main/list.css | 3 +- 6 files changed, 157 insertions(+), 84 deletions(-) diff --git a/src/common/UrlTool.js b/src/common/UrlTool.js index 7980ed0c..5b101e7a 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -11,15 +11,11 @@ export function getImageUrl(path) { // https://www.educoder.net // https://testbdweb.trustie.net // const local = 'http://localhost:3000' - const local = 'https://testforgeplus.trustie.net/'; - if(path.indexOf("http://")===-1){ - if (isDev) { - return `${local}/${path}` - } - return `/${path}`; - }else{ - return path; + const local = 'https://testforgeplus.trustie.net'; + if (isDev) { + return `${local}/${path}` } + return `/${path}`; } export function getImage(path) { diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 26b688b3..d51b0f99 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -183,47 +183,53 @@ class CoderRootDirectory extends Component { // 获取子目录 getFileDetail = (path, ref) => { const { projectsId ,owner } = this.props.match.params; - const { branch } = this.state; + const { branch , chooseType } = this.state; const url = `/${owner}/${projectsId}/sub_entries.json`; axios.get(url,{ params:{ filepath:path, - ref:ref || branch + ref:ref || branch, + type:chooseType } }).then((result)=>{ let entries = result.data && result.data.entries; this.setState({ isSpin:false }) - if( entries && entries.length > 0){ - let { chooseType } = this.state; - // 当前返回的子目录只有一条数据,且这条数据返回的是文件类型 - if(entries.length === 1 && entries[0].type === "file" && chooseType ==="file"){ - this.setState({ - fileDetail:entries, - rootList:undefined, - subFileType:false - }) + if(result){ + if( entries && entries.length > 0){ + let { chooseType } = this.state; + // 当前返回的子目录只有一条数据,且这条数据返回的是文件类型 + if(entries.length === 1 && entries[0].type === "file" && chooseType ==="file"){ + this.setState({ + fileDetail:entries, + rootList:undefined, + subFileType:false + }) + }else{ + this.setState({ + fileDetail:undefined, + rootList:entries, + branchLastCommit:result.data.last_commit && result.data.last_commit.commit, + lastCommitAuthor:result.data.last_commit && (result.data.last_commit.author || (result.data.last_commit.commit && result.data.last_commit.commit.author)) + }) + this.renderData(entries); + } }else{ this.setState({ fileDetail:undefined, - rootList:entries, - branchLastCommit:result.data.last_commit && result.data.last_commit.commit, - lastCommitAuthor:result.data.last_commit && (result.data.last_commit.author || (result.data.last_commit.commit && result.data.last_commit.commit.author)) + rootList:undefined, + isSpin:false, + subFileType:false }) - this.renderData(entries); } - }else{ - this.setState({ - fileDetail:undefined, - rootList:undefined, - isSpin:false, - subFileType:false - }) } }) .catch((error) => { + this.setState({ + isSpin:false + }) console.log(error); }); }; @@ -405,7 +411,8 @@ class CoderRootDirectory extends Component { render(){ const { branchLastCommit , lastCommitAuthor , rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state; - const { isManager , isDeveloper , projectDetail } = this.props; + const { isManager , isDeveloper , projectDetail , platform } = this.props; + const { projectsId , owner } = this.props.match.params; const columns = [ { @@ -447,13 +454,19 @@ class CoderRootDirectory extends Component {
- + { + platform ? + + : + 分支:master + } + {filePath && ( @@ -480,7 +493,7 @@ class CoderRootDirectory extends Component { )}
- {subFileType && (projectDetail && parseInt(projectDetail.type)) !== 2 && (isManager || isDeveloper) && ( + {subFileType && (projectDetail && parseInt(projectDetail.type)) !== 2 && (isManager || isDeveloper) && platform && (
diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 7ee916f7..2dcdcac3 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -168,6 +168,9 @@ class Detail extends Component { firstSync:false, secondSync:false, open_devops:false, + + // 非本平台项目 + platform:false } } @@ -190,7 +193,8 @@ class Detail extends Component { if (result && result.data) { this.setState({ project: result.data, - open_devops:result.data.open_devops + open_devops:result.data.open_devops, + platform:result.data.platform && result.data.platform !== 'educoder' }) // 工作流:两种状态进入的链接不同 @@ -284,8 +288,10 @@ class Detail extends Component { // 关注和取消关注 focusFunc = (flag) => { - const { project_id } = this.state; + const { platform } = this.state; + if(!platform)return; + const { project_id } = this.state; axios({ method: flag ? 'delete' : 'post', url: `/watchers/${flag ? 'unfollow' : 'follow'}.json`, @@ -305,6 +311,8 @@ class Detail extends Component { // 点赞和取消点赞 pariseFunc = (flag) => { + const { platform } = this.state; + if(!platform)return; const { project_id } = this.state; axios({ method: flag ? 'delete' : 'post', @@ -335,6 +343,8 @@ class Detail extends Component { // fork项目 forkFunc = () => { + const { platform } = this.state; + if(!platform)return; const { current_user } = this.props const { projectsId , owner } = this.props.match.params; const url = `/${owner}/${projectsId}/forks.json`; @@ -350,6 +360,8 @@ class Detail extends Component { // 同步镜像 synchronismMirror = () => { + const { platform } = this.state; + if(!platform)return; const { projectsId , owner } = this.props.match.params; const url = `/${owner}/${projectsId}/sync_mirror.json`; axios.post(url).then(result => { @@ -369,8 +381,7 @@ class Detail extends Component { const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, - project , open_devops } = this.state; - + project , open_devops , platform } = this.state; const url = this.props.history.location.pathname; const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); @@ -439,30 +450,45 @@ class Detail extends Component { 同步镜像 : "" } - this.focusFunc(watched)}> + this.focusFunc(watched)}> {watched ? '取消关注' : '关注'} - - {watchers_count} - + { + platform ? + + {watchers_count} + + : + {watchers_count} + } + - this.pariseFunc(praised)}> + this.pariseFunc(praised)}> {praised ? '取消点赞' : '点赞'} - - {praises_count} - + { + platform ? + + {praises_count} + : + {praises_count} + } - + Fork - - {forked_count} - + { + platform ? + + {forked_count} + + : + {praises_count} + } } @@ -491,7 +517,7 @@ class Detail extends Component { { - projectDetail && parseInt(projectDetail.type) !== 2 && + projectDetail && parseInt(projectDetail.type) !== 2 && platform &&
  • @@ -500,12 +526,16 @@ class Detail extends Component {
  • } -
  • - - 工作流(beta版) - {projectDetail && projectDetail.ops_count ? {projectDetail.ops_count} : ""} - -
  • + { + platform && +
  • + + 工作流(beta版) + {projectDetail && projectDetail.ops_count ? {projectDetail.ops_count} : ""} + +
  • + } +
  • @@ -520,7 +550,7 @@ class Detail extends Component {
  • { - isManager && + isManager && platform &&
  • 0 ? "active" : ""}> 0 ? "iconfont icon-cangku color-grey-3 mr5 font-14":"iconfont icon-cangku color-grey-6 font-14 mr5"}> diff --git a/src/forge/Main/DetailTop.js b/src/forge/Main/DetailTop.js index bf6fc4c4..5dcd240d 100644 --- a/src/forge/Main/DetailTop.js +++ b/src/forge/Main/DetailTop.js @@ -3,27 +3,53 @@ import { Link } from 'react-router-dom'; class DetailTop extends Component { render() { - const { coderCount } = this.props; + const { coderCount , platform } = this.props; const { projectsId, owner } = this.props.match.params; const { pathname } = this.props.location; return (

    - 0 ? "active" : ""}> - - {(coderCount && coderCount.commits_count) || 0}个提交 - - 0 ? "active" : ""}> - - {(coderCount && coderCount.branches_count) || 0}个分支 - - 0 ? "active" : ""}> - - {(coderCount && coderCount.tags_count) || 0}个标签 - - 0 ? "active" : ""}> - - {(coderCount && coderCount.version_releasesed_count) || 0}个发行版 - + + { + platform ? + + 0 ? "active" : ""}> + + {(coderCount && coderCount.commits_count) || 0}个提交 + + 0 ? "active" : ""}> + + {(coderCount && coderCount.branches_count) || 0}个分支 + + 0 ? "active" : ""}> + + {(coderCount && coderCount.tags_count) || 0}个标签 + + 0 ? "active" : ""}> + + {(coderCount && coderCount.version_releasesed_count) || 0}个发行版 + + + : + + + + {(coderCount && coderCount.commits_count) || 0}个提交 + + + + {(coderCount && coderCount.branches_count) || 0}个分支 + + + + {(coderCount && coderCount.tags_count) || 0}个标签 + + + + {(coderCount && coderCount.version_releasesed_count) || 0}个发行版 + + + } + 仓库 {(coderCount && coderCount.size) || 0} diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index 7950d6e1..698f0bed 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -20,9 +20,16 @@ class IndexItem extends Component { projects && projects.length > 0 ? projects.map((item, key) => { return (

    - - - + { + item.platform === "educoder" ? + + + + : + + + + }
    diff --git a/src/forge/Main/list.css b/src/forge/Main/list.css index 6668fd2f..c3006fd7 100644 --- a/src/forge/Main/list.css +++ b/src/forge/Main/list.css @@ -261,7 +261,7 @@ } .detail_tag_btn_name{ padding:0px 10px; - color: #666; + color: #666!important; } .detail_tag_btn_name img{ margin-right: 10px; @@ -294,6 +294,7 @@ .branch-wrapper > a >i{ color: #5091FF; margin-right: 5px; + cursor: default; } .branch-wrapper a{ display: flex;