forked from Gitlink/forgeplus-react
Merge pull request '代码库二级页面issue中readme更改' (#99) from hc1913847458/forgeplus-react:feature_repo_second_page into feature_repo_second_page
This commit is contained in:
commit
030c6ad61f
|
@ -67,14 +67,14 @@ function CoderDepot(props){
|
|||
const [ editReadme , setEditReadme ] = useState(false);
|
||||
const [ pullsFlag , setPullsFlag ] = useState(true);
|
||||
const [ issuesFlag , setIssuesFlag ] = useState(true);
|
||||
const [ releaseVersions , setReleaseVersions] = useState(undefined);
|
||||
|
||||
const details = props.projectDetail;
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
let branchName = props.match.params.branchName;
|
||||
branchName = returnbar(branchName);
|
||||
const details = props.projectDetail;
|
||||
let pathname = props.history.location.pathname;
|
||||
|
||||
const { bannerList } = props;
|
||||
|
||||
useEffect(()=>{
|
||||
|
@ -90,6 +90,7 @@ function CoderDepot(props){
|
|||
}
|
||||
},[bannerList])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(details){
|
||||
setProjectDetail(details);
|
||||
|
@ -99,7 +100,7 @@ function CoderDepot(props){
|
|||
setDefaultBranch(details.default_branch);
|
||||
setInviteCode(details.invite_code);
|
||||
}
|
||||
})
|
||||
},[details])
|
||||
|
||||
useEffect(()=>{
|
||||
if(treeValue){
|
||||
|
@ -118,30 +119,40 @@ function CoderDepot(props){
|
|||
setTreeValue(url);
|
||||
getFileInfo(url,branchName);
|
||||
setType("file");
|
||||
getReadmeInfo(url,branchName);
|
||||
}else{
|
||||
setTreeValue(undefined);
|
||||
getDirInfo(branchName || defaultBranch);
|
||||
setType("dir");
|
||||
getReadmeInfo('', branchName || defaultBranch);
|
||||
}
|
||||
}
|
||||
},[projectsId,owner,pathname,defaultBranch])
|
||||
|
||||
useEffect(()=>{
|
||||
axios.get(`/${owner}/${projectsId}/releases.json`).then((result)=>{
|
||||
if(result && result.data){
|
||||
const release = {
|
||||
"list":result.data.releases,
|
||||
"total_count":result.data.releases.length
|
||||
}
|
||||
setReleaseVersions(release);
|
||||
// 获取readme信息
|
||||
function getReadmeInfo(path, ref) {
|
||||
axios.get(`/${owner}/${projectsId}/readme.json`, {
|
||||
params:{
|
||||
owner: owner,
|
||||
repo: projectsId,
|
||||
filepath:path,
|
||||
ref:ref || branchName
|
||||
}
|
||||
}).then((result) => {
|
||||
console.log('getReadmeInfo', result)
|
||||
if (result) {
|
||||
setReadme(result.data);
|
||||
} else {
|
||||
setReadme(undefined);
|
||||
}
|
||||
})
|
||||
},[])
|
||||
}
|
||||
|
||||
// 获取主目录列表
|
||||
function getDirInfo(branch){
|
||||
setIsSpin(true);
|
||||
const url = `/${owner}/${projectsId}/entries.json`;
|
||||
|
||||
axios.get(url, {
|
||||
params: { ref: branch }
|
||||
}).then((result) => {
|
||||
|
@ -156,7 +167,7 @@ function CoderDepot(props){
|
|||
setLastCommitAuthor(c && c.committer);
|
||||
setMainFlag(true);
|
||||
setReadOnly(true);
|
||||
setReadme(result.data.readme);
|
||||
// setReadme(result.data.readme);
|
||||
setEditReadme(false);
|
||||
setHide(true);
|
||||
}
|
||||
|
@ -201,7 +212,7 @@ function CoderDepot(props){
|
|||
setLastCommit(c && c.commit);
|
||||
setLastCommitAuthor(c && c.committer);
|
||||
setMainFlag(false);
|
||||
setReadme(result.data.readme)
|
||||
// setReadme(result.data.readme);
|
||||
setReadOnly(true);
|
||||
setReadOnly(!editReadme);
|
||||
setHide(true);
|
||||
|
@ -532,13 +543,13 @@ function CoderDepot(props){
|
|||
}
|
||||
{/* 发布 */}
|
||||
{
|
||||
releaseVersions &&
|
||||
projectDetail && projectDetail.release_versions &&
|
||||
<React.Fragment>
|
||||
<Divider />
|
||||
<Releases
|
||||
owner={owner}
|
||||
projectsId={projectsId}
|
||||
releaseVersions={releaseVersions}
|
||||
releaseVersions={projectDetail.release_versions}
|
||||
history={props.history}
|
||||
baseOperate={baseOperate}
|
||||
projectType={projectDetail.type}
|
||||
|
|
Loading…
Reference in New Issue