forked from Gitlink/forgeplus-react
feat: 修改展示的为代码形式
This commit is contained in:
parent
0ba4c28f21
commit
f4103c5516
|
@ -1,7 +1,11 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import MonacoEditor from '../../components/monaco-editor/index'
|
||||
import Meditor from "../Newfile/m_editor";
|
||||
// import Meditor from "../Newfile/m_editor";
|
||||
|
||||
import codesmell from '../Images/quality/codesmell.svg'
|
||||
import bug from '../Images/quality/bug.svg'
|
||||
import semibold from '../Images/quality/semibold.svg'
|
||||
import bugRed from '../Images/quality/bug-red.svg'
|
||||
import {Button} from "antd";
|
||||
import axios from "axios";
|
||||
|
@ -13,7 +17,7 @@ function Quality(props){
|
|||
const [statuts,setStatus] = useState(-1)
|
||||
const [questionList,setQuestionList] = useState([]) //对应问题列表
|
||||
const [isDetail,setDetail] = useState(false) //对应问题列表
|
||||
const [codeDetailValue,setCodeDetailValue] = useState([]) //对应问题列表
|
||||
const [codeDetailValue,setCodeDetailValue] = useState("") //对应问题列表
|
||||
const severityList = {
|
||||
'BLOCKER': "阻断",
|
||||
"MINOR":"次要",
|
||||
|
@ -65,12 +69,15 @@ function Quality(props){
|
|||
const handlecheck = () => {
|
||||
if(statuts === 2 ) return
|
||||
setStatus(2)
|
||||
getTaskDetail(sonarList.task_id)
|
||||
getTaskData()
|
||||
}
|
||||
const getCodeDetailData = (item) => {
|
||||
axios.get(`/${owner}/${projectsId}/sonar_tasks/code_source.json?component=${item.component}&task_id=${sonarList.task_id}`)
|
||||
.then(({data:{data,message,status}})=>{
|
||||
setCodeDetailValue(data)
|
||||
const text = data.map(item => item.code).join("\n")
|
||||
const dom = document.createElement("div");
|
||||
dom.innerHTML = text;
|
||||
setCodeDetailValue(dom.innerText)
|
||||
})
|
||||
}
|
||||
const handleCodeDetail = (item) => {
|
||||
|
@ -80,9 +87,7 @@ function Quality(props){
|
|||
const handleBack = () => {
|
||||
setDetail(false)
|
||||
}
|
||||
const codeDetailValueMethod = () => {
|
||||
|
||||
}
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="wrap">
|
||||
|
@ -90,8 +95,8 @@ function Quality(props){
|
|||
<div className="wrap-header">
|
||||
<div className="quality">
|
||||
<div className="quality-fill mr35"><img alt='' src={bug}/>Bug<span className="ml3">{sonarList.bugs}</span></div>
|
||||
{/* <div className="quality-fill mg35"><img alt='' src={semibold}/>Security<span className="ml3">{sonarList.bugs}</span></div> */}
|
||||
<div className="quality-fill mr35"><img alt='' src={codesmell}/>Codesmell<span className="ml3">{sonarList.codeSmell}</span></div>
|
||||
<div className="quality-fill mr35"><img alt='' src={semibold}/>Security<span className="ml3">{sonarList.bugs}</span></div>
|
||||
<div className="quality-fill mr35"><img alt='' src={codesmell}/>Codesmell<span className="ml3">{sonarList.vulnerability}</span></div>
|
||||
<div>
|
||||
<div className="quality-total mr20">代码量统计:{sonarList.codeLines}</div>
|
||||
{/* <div className="quality-total mr20">代码量统计:{sonarList.codeLines}</div> */}
|
||||
|
@ -115,8 +120,17 @@ function Quality(props){
|
|||
</div>:
|
||||
<div className="wrap-code">
|
||||
<Button type="primary" onClick={handleBack} >返回</Button>
|
||||
<div className='span'>
|
||||
<MonacoEditor
|
||||
<div className='span'></div>
|
||||
{/* {codeDetailValue.length >0 && <div dangerouslySetInnerHTML={{__html:codeDetailValue.map(item => item.code).join("<br/>")}}/>} */}
|
||||
<Meditor
|
||||
content={
|
||||
codeDetailValue || "" //.map(item => item.code).join("\n")
|
||||
}
|
||||
readOnly={true}
|
||||
editorType="update"
|
||||
// currentBranch={currentBranch}
|
||||
/>
|
||||
{/* <MonacoEditor
|
||||
height="100vh"
|
||||
width="100%"
|
||||
value={codeDetailValue.map(item => item.code).join("\n")}
|
||||
|
@ -126,8 +140,7 @@ function Quality(props){
|
|||
"minimap": { "enabled": false },
|
||||
"lineNumbers":false
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
/> */}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue