diff --git a/public/react/src/forge/Index.js b/public/react/src/forge/Index.js index f4f512f44..3f48c287f 100644 --- a/public/react/src/forge/Index.js +++ b/public/react/src/forge/Index.js @@ -48,13 +48,12 @@ class Index extends Component{ const {current_user} = this.state; return( - () } > - - () } diff --git a/public/react/src/forge/Main/CoderRootBranch.js b/public/react/src/forge/Main/CoderRootBranch.js new file mode 100644 index 000000000..e54712666 --- /dev/null +++ b/public/react/src/forge/Main/CoderRootBranch.js @@ -0,0 +1,37 @@ +import React , { Component } from 'react'; + +import axios from 'axios'; + +class CoderRootBranch extends Component { + constructor(porps){ + super(porps); + this.state={ + data:undefined + } + } + + componentDidMount=()=>{ + this.getBranchList(); + } + + getBranchList=()=>{ + const { projectsId } = this.props.match.params; + const url = `/projects/${projectsId}/branches.json`; + axios.get(url).then((result)=>{ + if(result){ + this.setState({ + data:result.data + }) + } + }).catch(error=>{console.log(error)}) + } + + render(){ + return( +
bbbbbbbbbb
+ ) + } + +} + +export default CoderRootBranch; \ No newline at end of file diff --git a/public/react/src/forge/Main/CoderRootCommit.js b/public/react/src/forge/Main/CoderRootCommit.js new file mode 100644 index 000000000..565124052 --- /dev/null +++ b/public/react/src/forge/Main/CoderRootCommit.js @@ -0,0 +1,129 @@ +import React , { Component } from 'react'; +import { Table } from 'antd'; +import { getImageUrl } from 'educoder'; +import SelectBranch from '../Branch/SelectBranch'; + +import axios from 'axios'; + +class CoderRootCommit extends Component{ + constructor(props){ + super(props) + this.state={ + branch:"master", + data:undefined, + dataCount:undefined, + limit:30, + page:1 + } + } + + componentDidMount=()=>{ + this.getCommitList(); + } + + getCommitList=()=>{ + const { login } = this.props.current_user; + const { projectsId } = this.props.match.params; + + const { branch , page , limit } = this.state; + const url = `/${login}/${projectsId}/commits.json`; + axios.get(url,{ + params:{ + sha:branch, + page, + limit + } + }).then((result)=>{ + if(result){ + const array = []; + result.data && result.data.commits.length > 0 && result.data.commits.map((item,key)=>{ + array.push({ + name:item.author && item.author.name, + image_url:item.author && item.author.image_url, + sha:item.sha, + time_from_now:item.time_from_now, + message:item.message + }) + }) + this.setState({ + data:array, + dataCount:result.data.total_count + }) + } + }).catch((error)=>{console.log(error)}) + } + + changeBranch=(value)=>{ + const { branchList } = this.props; + let branchLastCommit = branchList[parseInt(value.key)]; + + this.setState({ + branch:branchLastCommit.name, + }) + } + + render(){ + const { branch , data , dataCount } = this.state; + const { branchs } = this.props; + const columns=[{ + title:"作者", + dataIndex: 'name', + width:"10%", + render: (text,item) => ( + + + + + ), + },{ + title:"SHA", + dataIndex: 'sha', + render: (text) => ( + {text} + ) + },{ + title:"备注", + dataIndex: 'message', + render: (text) => ( + {text} + ) + },{ + title:"提交时间", + className:"edu-txt-right", + dataIndex: 'time_from_now', + render: (text) => ( + {text} + ) + }] + + const title =()=>{ + return( +
+ {dataCount}次提交代码({branch}) + {/*
+ + 所有分支 + 搜索 +
*/} +
+ ) + } + return( +
+
+ +
+ title()} + /> + + ) + } +} +export default CoderRootCommit; \ No newline at end of file diff --git a/public/react/src/forge/Main/CoderRootDirectory.js b/public/react/src/forge/Main/CoderRootDirectory.js index 5e6be652e..4693a8cb6 100644 --- a/public/react/src/forge/Main/CoderRootDirectory.js +++ b/public/react/src/forge/Main/CoderRootDirectory.js @@ -1,14 +1,14 @@ import React , { Component } from 'react'; -import { Dropdown , Icon , Menu , Table } from 'antd'; -import {Link} from 'react-router-dom'; - +import { Menu , Table } from 'antd'; import { getImageUrl } from 'educoder'; -import axios from 'axios'; +import {Link} from 'react-router-dom'; -import SelectBranch from '../Branch/SelectBranch' -import CloneAddress from '../Branch/CloneAddress' +import './list.css'; +import SelectBranch from '../Branch/SelectBranch'; +import CloneAddress from '../Branch/CloneAddress'; +import axios from 'axios'; class CoderRootDirectory extends Component{ constructor(props){ super(props); @@ -17,13 +17,10 @@ class CoderRootDirectory extends Component{ branch:"master", http_url:undefined, - rootList:undefined, branchList:undefined, - branchs:undefined, branchLastCommit:undefined } } - changeAddress=(address)=>{ this.setState({ address @@ -32,32 +29,6 @@ class CoderRootDirectory extends Component{ componentDidMount=()=>{ this.getProjectRoot(); - this.getBranch(); - } - - // 获取分支列表 - getBranch=()=>{ - const { projectsId } = this.props.match.params; - - const url =`/projects/${projectsId}/branches.json`; - axios.get(url).then((result)=>{ - if(result && result.data.length>0){ - const branchs = []; - result.data.map((item,key)=>{ - branchs.push({ - index:key, - name:item.name - }) - }) - - this.setState({ - branchList:result.data, - branchs, - branchLastCommit:result.data[0], - http_url:result.data[0].http_url - }) - } - }).catch((error)=>{}) } // 获取分支文件 @@ -101,10 +72,10 @@ class CoderRootDirectory extends Component{ http_url:branchLastCommit.http_url }) } - render(){ - + const { rootList } = this.state; + const { branchs , branch , branchLastCommit , http_url } = this.props; const columns = [ { dataIndex: 'name', @@ -114,10 +85,6 @@ class CoderRootDirectory extends Component{ ), } ]; - - const { branch , rootList , branchs, branchLastCommit , http_url } = this.state; - - const title = () =>{ if(branchLastCommit && branchLastCommit.last_commit){ return( @@ -139,7 +106,6 @@ class CoderRootDirectory extends Component{ return undefined; } } - const downloadUrl = ()=>{ if(branchLastCommit && branchLastCommit.zip_url){ return( @@ -151,12 +117,7 @@ class CoderRootDirectory extends Component{ } } return( -
-

- 提交 - 分支 -

- +
diff --git a/public/react/src/forge/Main/CoderRootIndex.js b/public/react/src/forge/Main/CoderRootIndex.js new file mode 100644 index 000000000..3cc2ad6be --- /dev/null +++ b/public/react/src/forge/Main/CoderRootIndex.js @@ -0,0 +1,96 @@ +import React , { Component } from 'react'; +import { Route , Switch , Link} from 'react-router-dom'; + +import Loadable from 'react-loadable'; +import Loading from '../../Loading'; + +import axios from 'axios'; + + +const CoderRootDirectory = Loadable({ + loader: () => import('./CoderRootDirectory'), + loading: Loading, +}) +const CoderRootCommit = Loadable({ + loader: () => import('./CoderRootCommit'), + loading: Loading, +}) +const CoderRootBranch = Loadable({ + loader: () => import('./CoderRootBranch'), + loading: Loading, +}) +class CoderRootIndex extends Component{ + constructor(props){ + super(props); + this.state={ + branchs:undefined, + branchList:undefined, + branchLastCommit:undefined, + http_url:undefined + } + } + componentDidMount=()=>{ + this.getBranch(); + } + // 获取分支列表 + getBranch=()=>{ + const { projectsId } = this.props.match.params; + + const url =`/projects/${projectsId}/branches.json`; + axios.get(url).then((result)=>{ + if(result && result.data.length>0){ + const branchs = []; + result.data.map((item,key)=>{ + branchs.push({ + index:key, + name:item.name + }) + }) + + this.setState({ + branchList:result.data, + branchs, + branchLastCommit:result.data[0], + http_url:result.data[0].http_url + }) + } + }).catch((error)=>{}) + } + render(){ + const { projectsId } = this.props.match.params; + const { pathname } = this.props.location; + return( +
+

+ 0 ? "active" : ""}>提交 + 0 ? "active" : ""}>分支 +

+ + + () + } + > + + () + } + > + () + } + > + () + } + > + +
+ ) + } +} +export default CoderRootIndex; \ No newline at end of file diff --git a/public/react/src/forge/Main/Detail.js b/public/react/src/forge/Main/Detail.js index d22f1fe67..325c54a55 100644 --- a/public/react/src/forge/Main/Detail.js +++ b/public/react/src/forge/Main/Detail.js @@ -6,35 +6,58 @@ import './list.css'; import Loadable from 'react-loadable'; import Loading from '../../Loading'; + +import axios from 'axios'; const CoderRootDirectory = Loadable({ loader: () => import('./CoderRootDirectory'), loading: Loading, }) +const CoderRootIndex = Loadable({ + loader: () => import('./CoderRootIndex'), + loading: Loading, +}) class Detail extends Component{ constructor(props){ super(props); this.state={ - currentKey:"coder" + currentKey:"coder", + data:undefined } } - // 切换菜单 - ChangeMenu=(value)=>{ - console.log(value); + componentDidMount=()=>{ + this.getDetail(); + } + + getDetail=()=>{ + const { login } = this.props.current_user; + const { projectsId } = this.props.match.params; + const url = `/${login}/${projectsId}.json`; + axios.get(url).then((result)=>{ + if(result){ + this.setState({ + data:result.data + }) + } + }).catch((error)=>{}) } + render(){ const { currentKey } = this.state; const { projectsId } = this.props.match.params; + + const { data } = this.state; + return(
-

kosasa胡 / test11111111111

+

{data && data.author && data.author.name} / { data && data.identifier }

- 11 - 12 - 11 + {data && data.watchers_count} + {data && data.praises_count} + {data && data.forked_count}
@@ -49,14 +72,10 @@ class Detail extends Component{
- () - } - > - () + (props) => () } > diff --git a/public/react/src/forge/Main/list.css b/public/react/src/forge/Main/list.css index 9921e55a4..549b71a22 100644 --- a/public/react/src/forge/Main/list.css +++ b/public/react/src/forge/Main/list.css @@ -186,7 +186,7 @@ body,#root{ display: flex; padding:5px; } -.branch-wrapper span{ +.branch-wrapper a{ display: flex; align-items: center; justify-content: center; @@ -197,10 +197,10 @@ body,#root{ cursor: pointer; font-size: 16px; } -.branch-wrapper span.active{ +.branch-wrapper a.active{ background: #eee; } -.branch-wrapper span:hover{ +.branch-wrapper a:hover{ color: #4CACFF; } @@ -252,6 +252,9 @@ body,#root{ border-radius: 4px; max-width: 100%; } +/* 提交 */ + + @media screen and (max-width: 750px){ .list-left,.list-right{ diff --git a/public/react/src/forge/css/index.css b/public/react/src/forge/css/index.css index 6306ff9a0..9d4cf00fc 100644 --- a/public/react/src/forge/css/index.css +++ b/public/react/src/forge/css/index.css @@ -11,6 +11,9 @@ .back-white{ background: #fff; } +.back-black{ + background: #000; +} /* 灰色按钮-高度32 */ .btn_32{ border-radius: 4px;