态势感知平台-开源生态与贡献价值全景接口字段修改

This commit is contained in:
d266377
2026-01-30 11:08:30 +08:00
parent 15b04e6788
commit 7b59d3ac9c
8 changed files with 47 additions and 37 deletions

View File

@@ -30,11 +30,12 @@ const fetchDataFromApi = async () => {
try {
loading.value = true;
const response = await communityHealthPage2();
const businessData = response.data; // Axios响应格式业务数据在response.data中
if (response.code === 200 && response.data) {
communityHealthData.value = 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 },

View File

@@ -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 = [
{

View File

@@ -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' },

View File

@@ -62,9 +62,10 @@ const fetchStats = async () => {
try {
loading.value = true;
const response = await overviewDataPage2();
const businessData = response.data; // Axios响应格式业务数据在response.data中
if (response.code === 200 && response.data) {
const { developer, project, company, valuation } = 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万+';

View File

@@ -23,11 +23,12 @@ const fetchDataFromApi = async () => {
try {
loading.value = true;
const response = await universityClubsPage2();
const businessData = response.data; // Axios响应格式业务数据在response.data中
if (response.code === 200 && response.data) {
universityClubData.value = response.data;
if (businessData?.code === 200 && businessData.data) {
universityClubData.value = businessData.data;
} else {
console.error('获取高校开源社团数据失败:', response.msg || '未知错误');
console.error('获取高校开源社团数据失败:', businessData?.msg || '未知错误');
// 设置默认数据
universityClubData.value = [
// 华东地区

View File

@@ -42,13 +42,14 @@ const fetchDataFromApi = async () => {
try {
loading.value = true;
const response = await vitalityPage2();
const businessData = response.data; // Axios响应格式业务数据在response.data中
if (response.code === 0 && 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"],

View File

@@ -43,10 +43,11 @@ const fetchDataFromApi = async () => {
try {
loading.value = true;
const response = await talentMapDataPage2();
const businessData = response.data; // Axios响应格式业务数据在response.data中
if (response.code === 0 && 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] },

View File

@@ -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'],