From 718d3da8c989c335194c765fcead12ebd90aa5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Wed, 6 Nov 2024 15:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=BA=90=E5=81=A5=E5=BA=B7=E6=88=90?= =?UTF-8?q?=E7=86=9F=E5=BA=A6=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/forge/Component/projectCompass.jsx | 229 +++++++++++++++++++++++++ src/forge/Main/CoderDepot.jsx | 2 + src/forge/api/project.js | 10 ++ 4 files changed, 242 insertions(+) create mode 100644 src/forge/Component/projectCompass.jsx create mode 100644 src/forge/api/project.js diff --git a/package.json b/package.json index f0c3872de..92e78eb7a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/forge/Component/projectCompass.jsx b/src/forge/Component/projectCompass.jsx new file mode 100644 index 000000000..f6837632e --- /dev/null +++ b/src/forge/Component/projectCompass.jsx @@ -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
+ 开源健康成熟度评分,评估围绕以下维度对项目展开评估:
+ 稳健性:由安全警告,开发者数量,版本数评分反映。
+ 扩展性:由许可证评分、fork数评分、点赞数评分、关注数评分反映。
+ 维护性:由未解决 issue 和已解决 issue,commit数评分反映。
+
+ 总体成熟度评分
+ 80-100分: 项目成熟,维护良好。
+ 60-80分: 项目稳定,有待改进。
+ 0-60分: 项目成长期,需要加强维护。
+
+ + } + + return( + mainScore.score && mainScore.score > 0 ?
+
+ 开源健康成熟度评分 ({ mainScore.score && mainScore.score.toFixed(2) }) + + + +
+
+
: null + ) +} +export default Compass; \ No newline at end of file diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index 163766edf..301134115 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -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){ /> } + {__CLIENT__ && } {/* 贡献者 */} {mirror_status ===0 && } {/* 项目画像: 导入/fork项目不展示, open_portrait后台配置是否开启仓库 */} diff --git a/src/forge/api/project.js b/src/forge/api/project.js new file mode 100644 index 000000000..bdc48e180 --- /dev/null +++ b/src/forge/api/project.js @@ -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 + }); +} \ No newline at end of file