开源健康成熟度评分

This commit is contained in:
黄心宇 2024-11-06 15:58:37 +08:00
parent 73754d777f
commit 718d3da8c9
4 changed files with 242 additions and 0 deletions

View File

@ -48,6 +48,7 @@
"dotenv": "4.0.0",
"dotenv-expand": "4.2.0",
"echarts": "^4.9.0",
"echarts-gl": "^1.1.2",
"echarts-wordcloud": "^2.0.0",
"editor.md": "^1.5.0",
"express": "^4.18.2",

View File

@ -0,0 +1,229 @@
import React ,{ Fragment, useEffect, useState } from 'react';
import echarts from 'echarts/lib/echarts'
import 'echarts-gl';
import { getmaturityAnalyse } from '../api/project'
import { Icon, Popover } from 'antd';
function Compass({owner,projectsId}) {
const [mainScore, setMainScore] = useState({})
useEffect(()=>{
getmaturityAnalyse({ owner, repository: projectsId }).then(res => {
if (res.data && res.data.main_score && res.data.main_score.score > 0) {
setMainScore(res.data.main_score)
Init(res.data)
}
})
},[])
function Init(data) {
let huan_val = document.getElementById("compass");
let myEcharts = echarts.init(huan_val);
const a = 3;
const n = 3;
const o = false;
const l = o ? "white" : "#333"
, r = o ? "rgba(255,255,255,0.8)" : "#aaa";
let option = {
tooltip: {
textStyle: {
fontWeight: "bolder"
},
formatter: e => "mock" === e.data.validity ? e.name + ": \u5373\u5c06\u4e0a\u7ebf" : e.data.description + ": " + e.data.value[2]
},
xAxis3D: {
name: " ",
type: "category",
data: data.main_score.x_axis,
interval: 2,
axisLine: {
lineStyle: {
width: 1,
color: l
}
},
splitLine: {
show: !0,
interval: a - 1
},
axisLabel: {
interval: a - 1,
textStyle: {
color: r,
padding: [10, 10, 0, 0]
}
},
axisTick: {
interval: a - 1,
length: 1
}
},
yAxis3D: {
name: " ",
type: "category",
data: data.main_score.y_axis,
axisLine: {
lineStyle: {
width: 1,
color: l
}
},
axisTick: {
interval: n - 1,
length: 0
},
splitArea: {
show: !0,
areaStyle: {
color: ["rgba(255,247,207,0.5)", "rgba(255,231,231,0.5)", "rgba(226,226,226,0.5)"]
}
},
axisLabel: {
interval: n - 1,
textStyle: {
color: r,
padding: [10, 0, 0, 0]
}
},
splitLine: {
show: !0,
interval: n - 1
}
},
zAxis3D: {
name: " ",
type: "value",
splitNumber: 4,
axisLine: {
lineStyle: o ? {
width: 1,
opacity: .2,
color: l
} : {
width: .1,
opacity: .5,
color: l
}
},
splitArea: {
show: !0,
areaStyle: {
color: ["#ffffff", "#ffffff", "#ffffff"]
}
},
axisLabel: {
show: !1
},
axisTick: {
show: !1
}
},
grid3D: {
axisLine: {
interval: 1
},
axisPointer: {
lineStyle: {
opacity: .2
},
label: {
show: !1
}
},
splitLine: {
interval: 2
},
viewControl: {
projection: "perspective",
zoomSensitivity: 0,
rotateSensitivity: [1, 0],
distance: 280,
alpha: 20,
beta: 25
},
top: -40,
right: -10,
boxWidth: 150,
boxDepth: 150,
environment: "none",
light: {
main: {
intensity: .8,
alpha: 50
},
ambient: {
intensity: .5
}
}
},
series: [{
type: "bar3D",
data: data.scores,
shading: "realistic",
bevelSize: .1,
bevelSmoothness: 2,
barSize: 13,
label: {
show: !1,
fontSize: 12,
fontWeight: 500,
borderWidth: 1,
color: "#333",
distance: -20,
formatter: function (e) {
for (let t = e.data.description, i = 2, a = Math.ceil(t.length / i), n = "\n", o = 0; o < a; o++) {
let l = o * i
, r = l + i;
n += t.substring(l, r) + "\n"
}
return n
}
},
itemStyle: {
opacity: .95
},
emphasis: {
label: {
show: !1
},
itemStyle: {
color: "#FFB800",
opacity: .7
}
}
}]
};
myEcharts.setOption(option);
}
const content = () => {
return <div>
开源健康成熟度评分评估围绕以下维度对项目展开评估<br/>
稳健性由安全警告开发者数量版本数评分反映<br/>
扩展性由许可证评分fork数评分点赞数评分关注数评分反映<br/>
维护性由未解决 issue 和已解决 issuecommit数评分反映<br/>
<br/>
总体成熟度评分<br/>
80-100: 项目成熟维护良好<br/>
60-80: 项目稳定有待改进<br/>
0-60: 项目成长期需要加强维护<br/>
</div>
}
return(
mainScore.score && mainScore.score > 0 ? <div className='halfs'>
<div className="font-16 color-ooo mb20">
开源健康成熟度评分 ({ mainScore.score && mainScore.score.toFixed(2) })
<Popover content={content()}>
<Icon type="question-circle" theme="filled" className="color-blue ml10 pointer"/>
</Popover>
</div>
<div id="compass" style={{height:"250px"}}></div>
</div> : null
)
}
export default Compass;

View File

@ -26,6 +26,7 @@ import RenderHtml from '../../components/render-html';
import Loadable from 'react-loadable';
import Loading from '../../Loading';
import ProjectPortrait from '../Component/projectPortrait';
import ProjectCompass from '../Component/projectCompass';
import imNoneImg from './img/importNone.png';
import moment from 'moment';
@ -694,6 +695,7 @@ function CoderDepot(props){
/>
</React.Fragment>
}
{__CLIENT__ && <ProjectCompass owner={owner} projectsId={projectsId} />}
{/* 贡献者 */}
{mirror_status ===0 && <Contributors owner={owner} projectsId={projectsId} /> }
{/* 项目画像: 导入/fork项目不展示, open_portrait后台配置是否开启仓库 */}

10
src/forge/api/project.js Normal file
View File

@ -0,0 +1,10 @@
import javaFetch from '../javaFetch';
const service = javaFetch();
export function getmaturityAnalyse(params) {
return service({
url: `https://testbd.trustie.net/maturityAnalyse/`,
method: 'get',
params: window.location.hostname === 'testforgeplus.trustie.net' ? { ...params, env_url: 'testforgeplus' } : params
});
}