forked from Gitlink/forgeplus-react
get issues
This commit is contained in:
parent
3172f09fdf
commit
b43f650946
|
|
@ -36,14 +36,21 @@ export default ({
|
|||
},[owner,projectsId])
|
||||
|
||||
function getIssueList(){
|
||||
axios.get(`/v1/${owner}/${projectsId}/issues`,{params:{
|
||||
only_name:true,sort_direction:"desc",sort_by:"issues.created_on"
|
||||
}}).then(result=>{
|
||||
if(result){
|
||||
let data = result.data.issues;
|
||||
setIssues(data);
|
||||
let matchQuote = str.match(quoteRegex);
|
||||
let array = [];
|
||||
if(matchQuote && matchQuote.length>0){
|
||||
for(var x=0;x<matchQuote.length;x++){
|
||||
let getIndex = matchQuote[x].match(/#(\S*)\]/)[1];
|
||||
getIndex && array.push(getIndex);
|
||||
}
|
||||
})
|
||||
axios.get(`/${owner}/${projectsId}/issues/index_to_name`,{params:{
|
||||
index:array
|
||||
}}).then(result=>{
|
||||
if(result){
|
||||
setIssues(result.data);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let str = String(value);
|
||||
|
|
@ -62,22 +69,10 @@ export default ({
|
|||
}
|
||||
}
|
||||
if(owner && projectsId && issues && issues.length>0){
|
||||
let matchQuote = str.match(quoteRegex);
|
||||
if(matchQuote && matchQuote.length>0){
|
||||
for(var x=0;x<matchQuote.length;x++){
|
||||
let getIndex = matchQuote[x].match(/#(\S*)\]/)[1];
|
||||
if(getIndex && getIndex.length>0 && getIndex[0]){
|
||||
let index = getIndex[0];
|
||||
let filter = issues.filter(f=>f.project_issues_index.toString() === index);
|
||||
if(filter && filter.length === 1){
|
||||
let content = `#${index}:${filter[0].subject}`;
|
||||
rs = rs.replaceAll(`#${index}`,content);
|
||||
}else{
|
||||
let content = `<span>#${index}(已删除)</span>`;
|
||||
rs = rs.replaceAll(`<a href="`+`/${owner}/${projectsId}/issues/${index}`+`">#${index}</a>`,content);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(var x=0;x<issues.length;x++){
|
||||
let item = issues[x];
|
||||
let content = item.id ? `<a href="`+`/${owner}/${projectsId}/issues/${item.project_issues_index}`+`">#${item.project_issues_index}:${item.subject}</a>` : `<span>#${item.project_issues_index}(已删除)</span>`;
|
||||
rs = rs.replaceAll(`<a href="`+`/${owner}/${projectsId}/issues/${item.project_issues_index}`+`">#${item.project_issues_index}</a>`,content);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue