态势感知平台-开源生态与贡献价值全景统计概览对接接口

This commit is contained in:
d266377
2026-01-28 15:09:53 +08:00
parent e66ca622f5
commit bcab3014ac
2 changed files with 77 additions and 18 deletions

View File

@@ -137,3 +137,12 @@ export function scatterDataPage1(params?: any): Promise<any> {
});
}
// 开源生态与贡献价值全景-统计概览
export function overviewDataPage2(params?: any): Promise<any> {
return request({
url: `/api/v1/page2/overviewData`,
method: 'get',
params
});
}

View File

@@ -23,26 +23,76 @@
</template>
<script lang="ts" setup>
import { defineProps } from 'vue';
import { ref, onMounted } from 'vue';
import { overviewDataPage2 } from '@/api/jyh/situation';
// 定义props便于从父组件或API获取数据
const props = defineProps({
activeDevelopers: {
type: String,
default: '200万+'
},
openSourceProjects: {
type: String,
default: '300万+'
},
openSourceCompanies: {
type: String,
default: '500+'
},
industryValuation: {
type: String,
default: '2800亿'
// 定义响应式数据
const activeDevelopers = ref<string>('加载中...');
const openSourceProjects = ref<string>('加载中...');
const openSourceCompanies = ref<string>('加载中...');
const industryValuation = ref<string>('加载中...');
// 加载状态
const loading = ref(true);
// 格式化数字的工具函数
const formatNumber = (num: number, unit: string = ''): string => {
if (num >= 100000000) {
return (num / 100000000).toFixed(1) + '亿';
} else if (num >= 10000) {
return (num / 10000).toFixed(1) + '万';
} else if (num >= 1000) {
return (num / 1000).toFixed(1) + '千';
}
return num.toString();
};
// 格式化估值的工具函数
const formatValuation = (num: number): string => {
if (num >= 100000000) {
return (num / 100000000).toFixed(1) + '亿';
} else if (num >= 10000) {
return (num / 10000).toFixed(1) + '万';
}
return num.toString() + '亿';
};
// 获取统计数据
const fetchStats = async () => {
try {
loading.value = true;
const response = await overviewDataPage2();
if (response.code === 200 && response.data) {
const { developer, project, company, valuation } = response.data;
// 格式化数据显示
activeDevelopers.value = `${formatNumber(developer)}+`;
openSourceProjects.value = `${formatNumber(project)}+`;
openSourceCompanies.value = `${formatNumber(company)}+`;
industryValuation.value = `${formatValuation(valuation)}`;
} else {
console.error('获取统计数据失败:', response.msg || '未知错误');
// 设置默认值
activeDevelopers.value = '200万+';
openSourceProjects.value = '300万+';
openSourceCompanies.value = '500+';
industryValuation.value = '2800亿';
}
} catch (error) {
console.error('获取统计数据异常:', error);
// 设置默认值
activeDevelopers.value = '200万+';
openSourceProjects.value = '300万+';
openSourceCompanies.value = '500+';
industryValuation.value = '2800亿';
} finally {
loading.value = false;
}
};
onMounted(() => {
fetchStats();
});
</script>