态势感知平台-开源生态与贡献价值全景接口字段修改
This commit is contained in:
@@ -30,11 +30,12 @@ const fetchDataFromApi = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await communityHealthPage2();
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
communityHealthData.value = response.data;
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
communityHealthData.value = businessData.data;
|
||||
} else {
|
||||
console.error('获取社区治理健康度数据失败:', response.msg || '未知错误');
|
||||
console.error('获取社区治理健康度数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
communityHealthData.value = [
|
||||
{ indicators: 'PR 合并率', github: 82, gitcode: 68 },
|
||||
|
||||
@@ -28,21 +28,22 @@ const infrastructureData = ref<InfrastructureItem[]>([]);
|
||||
const loading = ref(true);
|
||||
|
||||
// 从API获取数据
|
||||
const fetchDataFromApi = async () => {
|
||||
const fetchDataFromApi = async() => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await infrastructurePage2();
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
if (businessData.code === 200 && businessData.data) {
|
||||
// 为每个数据项添加颜色和半径配置
|
||||
infrastructureData.value = response.data.map((item: InfrastructureItem, index: number) => ({
|
||||
infrastructureData.value = businessData.data.map((item: InfrastructureItem, index: number) => ({
|
||||
name: item.name,
|
||||
value: item.value,
|
||||
color: baseColors[index % baseColors.length],
|
||||
radius: [`calc(${70 - index * 20}%)`, `calc(${80 - index * 20}%)`] // 根据索引计算半径
|
||||
radius: [`${70 - index * 20}%`, `${80 - index * 20}%`] // 根据索引计算半径,移除calc函数以避免潜在问题
|
||||
}));
|
||||
} else {
|
||||
console.error('获取基础设施覆盖率数据失败:', response.msg || '未知错误');
|
||||
console.error('获取基础设施覆盖率数据失败:', businessData.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
infrastructureData.value = [
|
||||
{
|
||||
|
||||
@@ -51,15 +51,16 @@ const fetchDataFromApi = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await excellentDeveloperPage2();
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
// 适配后端数据格式,将description映射为desc
|
||||
excellentProjects2025.value = response.data.map((item: any) => ({
|
||||
excellentProjects2025.value = businessData.data.map((item: any) => ({
|
||||
...item,
|
||||
desc: item.description
|
||||
}));
|
||||
} else {
|
||||
console.error('获取明星开发者数据失败:', response.msg || '未知错误');
|
||||
console.error('获取明星开发者数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
excellentProjects2025.value = [
|
||||
{ name: '稚晖', desc: 'TOP 1', org: 'Shanghai', followers: 82738, avatar: 'https://github.com/peng-zhihui.png' },
|
||||
|
||||
@@ -62,9 +62,10 @@ const fetchStats = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await overviewDataPage2();
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
const { developer, project, company, valuation } = response.data;
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
const { developer, project, company, valuation } = businessData.data;
|
||||
|
||||
// 格式化数据显示
|
||||
activeDevelopers.value = `${formatNumber(developer)}+`;
|
||||
@@ -72,7 +73,7 @@ const fetchStats = async () => {
|
||||
openSourceCompanies.value = `${formatNumber(company)}+`;
|
||||
industryValuation.value = `${formatValuation(valuation)}`;
|
||||
} else {
|
||||
console.error('获取统计数据失败:', response.msg || '未知错误');
|
||||
console.error('获取统计数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认值
|
||||
activeDevelopers.value = '200万+';
|
||||
openSourceProjects.value = '300万+';
|
||||
|
||||
@@ -23,11 +23,12 @@ const fetchDataFromApi = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await universityClubsPage2();
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
universityClubData.value = response.data;
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
universityClubData.value = businessData.data;
|
||||
} else {
|
||||
console.error('获取高校开源社团数据失败:', response.msg || '未知错误');
|
||||
console.error('获取高校开源社团数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
universityClubData.value = [
|
||||
// 华东地区
|
||||
|
||||
@@ -42,13 +42,14 @@ const fetchDataFromApi = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await vitalityPage2();
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
// 提取API返回的数据
|
||||
const apiTimeData: string[] = [];
|
||||
const apiTotalData: number[] = [];
|
||||
|
||||
response.data.forEach((item: VitalityItem) => {
|
||||
businessData.data.forEach((item: VitalityItem) => {
|
||||
apiTimeData.push(item.timeData);
|
||||
apiTotalData.push(item.total);
|
||||
});
|
||||
@@ -69,7 +70,7 @@ const fetchDataFromApi = async () => {
|
||||
new: apiNewData
|
||||
};
|
||||
} else {
|
||||
console.error('获取开发者活力数据失败:', response.msg || '未知错误');
|
||||
console.error('获取开发者活力数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
vitalityData.value = {
|
||||
timeData: ["2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024"],
|
||||
|
||||
@@ -43,10 +43,11 @@ const fetchDataFromApi = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await talentMapDataPage2();
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
// 转换API返回的数据格式为图表所需格式
|
||||
talentMapData.value = response.data.map((item: TalentMapItem) => {
|
||||
talentMapData.value = businessData.data.map((item: TalentMapItem) => {
|
||||
// 查找省份坐标,如果找不到则使用默认坐标
|
||||
let coordinates = [104.5, 37.5]; // 默认为中国中心坐标
|
||||
|
||||
@@ -97,7 +98,7 @@ const fetchDataFromApi = async () => {
|
||||
};
|
||||
});
|
||||
} else {
|
||||
console.error('获取人才地图数据失败:', response.msg || '未知错误');
|
||||
console.error('获取人才地图数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
talentMapData.value = [
|
||||
{ name: '北京市', value: [116.4074, 39.9042, 141.15, 231.47] },
|
||||
|
||||
@@ -249,11 +249,12 @@ const fetchEnterpriseData = async () => {
|
||||
try {
|
||||
enterpriseLoading.value = true;
|
||||
const response = await rawEnterpriseDataPage2();
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
rawEnterpriseData.value = response.data;
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
rawEnterpriseData.value = businessData.data;
|
||||
} else {
|
||||
console.error('获取企业数据失败:', response.msg || '未知错误');
|
||||
console.error('获取企业数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
rawEnterpriseData.value = [
|
||||
{ name: 'Microsoft', openrank: 177654.43, repos: 9211, devs: 14954, country: 'USA' },
|
||||
@@ -477,20 +478,21 @@ const fetchLanguageTechData = async () => {
|
||||
try {
|
||||
languageTechLoading.value = true;
|
||||
const response = await languageTechPage2();
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
// 将API返回的数据按类型分类
|
||||
const mainstreamLanguages = ['JavaScript', 'Python', 'HTML/CSS', 'Java', 'SQL', 'Shell'];
|
||||
const emergingLanguages = ['TypeScript', 'C++', 'C#', 'Go', 'Kotlin', 'C'];
|
||||
|
||||
const allData = response.data || [];
|
||||
const allData = businessData.data || [];
|
||||
|
||||
languageTechData.value = {
|
||||
mainstream: allData.filter(item => mainstreamLanguages.includes(item.name)),
|
||||
emerging: allData.filter(item => emergingLanguages.includes(item.name))
|
||||
};
|
||||
} else {
|
||||
console.error('获取语言与技术竞争数据失败:', response.msg || '未知错误');
|
||||
console.error('获取语言与技术竞争数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
languageTechData.value = {
|
||||
// 主流语言数据(基于2025年数据,增长率为2024→2025的变化)
|
||||
@@ -550,10 +552,11 @@ const fetchHeatmapData = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await projectHeatMapPage2();
|
||||
const businessData = response.data; // Axios响应格式,业务数据在response.data中
|
||||
|
||||
if (response.code === 0 && response.data) {
|
||||
if (businessData?.code === 200 && businessData.data) {
|
||||
// 转换API返回的数据格式为图表所需格式
|
||||
heatmapData.value = response.data.map((item: HeatmapDataItem) => [
|
||||
heatmapData.value = businessData.data.map((item: HeatmapDataItem) => [
|
||||
item.openrank,
|
||||
item.repo,
|
||||
item.developer,
|
||||
@@ -561,7 +564,7 @@ const fetchHeatmapData = async () => {
|
||||
item.org
|
||||
]);
|
||||
} else {
|
||||
console.error('获取热力图数据失败:', response.msg || '未知错误');
|
||||
console.error('获取热力图数据失败:', businessData?.msg || '未知错误');
|
||||
// 设置默认数据
|
||||
heatmapData.value = [
|
||||
[67538.71, 29433, 1409, 'OpenHarmony', 'Huawei'],
|
||||
|
||||
Reference in New Issue
Block a user