获取根目录-接口

dev_forge
caicai8 5 years ago
parent bab48d3b66
commit 69f696dc3e

@ -36,7 +36,8 @@ class Index extends Component{
} }
componentDidMount=()=>{ componentDidMount=()=>{
let current_user={ let current_user={
user_id:50207 user_id:50207,
login:'caicc'
} }
this.setState({ this.setState({
@ -53,7 +54,7 @@ class Index extends Component{
} }
></Route> ></Route>
<Route exact path="/projects/:projectId" <Route exact path="/projects/:projectsId"
render={ render={
(props) => (<ProjectDetail {...this.props} {...props} {...this.state} current_user={current_user}/>) (props) => (<ProjectDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
} }

@ -1,6 +1,7 @@
import React , { Component } from 'react'; import React , { Component } from 'react';
import { Dropdown , Icon , Menu , Table } from 'antd'; import { Dropdown , Icon , Menu , Table } from 'antd';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import axios from 'axios';
// 点击按钮复制功能 // 点击按钮复制功能
function jsCopy(){ function jsCopy(){
@ -12,7 +13,8 @@ class CoderRootDirectory extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state={ this.state={
address:"http" address:"http",
ref:"master"
} }
} }
@ -22,6 +24,26 @@ class CoderRootDirectory extends Component{
}) })
} }
componentDidMount=()=>{
this.getProjectRoot();
}
getProjectRoot=(ref)=>{
const { login } = this.props.current_user;
const { projectsId } = this.props.match.params;
const url = `/${login}/${projectsId}/entries.json`;
axios.get((url),{
params:{
ref
}
}).then((result)=>{
if(result){
}
}).catch((error)=>{})
}
render(){ render(){
const menu = ( const menu = (
<Menu> <Menu>
@ -84,7 +106,7 @@ class CoderRootDirectory extends Component{
) )
} }
const { address } = this.state; const { address , ref } = this.state;
return( return(
<div className="main"> <div className="main">
<p className="branch-wrapper"> <p className="branch-wrapper">
@ -97,7 +119,7 @@ class CoderRootDirectory extends Component{
<span className="color-grey-9 mr3"><i className="iconfont icon-fenzhi font-20 color-grey-6 mr3"></i>:</span> <span className="color-grey-9 mr3"><i className="iconfont icon-fenzhi font-20 color-grey-6 mr3"></i>:</span>
<Dropdown overlay={menu} trigger={['click']} placement="bottomRight"> <Dropdown overlay={menu} trigger={['click']} placement="bottomRight">
<a className="ant-dropdown-link"> <a className="ant-dropdown-link">
master <Icon type="down" /> {ref} <Icon type="down" />
</a> </a>
</Dropdown> </Dropdown>
</div> </div>

@ -48,12 +48,12 @@ class Detail extends Component{
</div> </div>
<Switch {...this.props}> <Switch {...this.props}>
<Route exact path="/projects/:projectsType/coder" <Route exact path="/projects/:projectsId/coder"
render={ render={
(props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>) (props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>)
} }
></Route> ></Route>
<Route exact path="/projects/:projectsType" <Route exact path="/projects/:projectsId"
render={ render={
(props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>) (props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>)
} }

@ -16,7 +16,7 @@ class IndexItem extends Component{
<img className="p-r-photo" alt="" src={getImageUrl(`images/${item.author && item.author.image_url}`)} ></img> <img className="p-r-photo" alt="" src={getImageUrl(`images/${item.author && item.author.image_url}`)} ></img>
<div className="p-r-Infos"> <div className="p-r-Infos">
<div className="p-r-name"> <div className="p-r-name">
<Link to={`/projects/${item.id}`} className="hide-1 font-16 color-grey-3" style={{whiteSpace:"wrap"}}>{item.name}</Link> <Link to={`/projects/${item.id}/root`} className="hide-1 font-16 color-grey-3" style={{whiteSpace:"wrap"}}>{item.name}</Link>
<span className="p-r-tags"> <span className="p-r-tags">
{ item.forked_count ? <span><label>Fork</label><span>{ item.forked_count}</span></span>:"" } { item.forked_count ? <span><label>Fork</label><span>{ item.forked_count}</span></span>:"" }
<span><label>Start</label><span>{ item.praises_count }</span></span> <span><label>Start</label><span>{ item.praises_count }</span></span>

Loading…
Cancel
Save