态势感知平台-武汉市开源生态建设-武汉优质开源项目榜接口对接

This commit is contained in:
d266377
2026-02-03 15:17:55 +08:00
parent 4f58ace30c
commit 7553c7ebd0

View File

@@ -311,10 +311,15 @@ import * as echarts from 'echarts';
import { usePageResize } from '@/utils/hooks/usePageResize'; import { usePageResize } from '@/utils/hooks/usePageResize';
import StatsBar from './components/StatsBar.vue'; import StatsBar from './components/StatsBar.vue';
import HarmonyEcoCharts from './components/HarmonyEcoCharts.vue'; import HarmonyEcoCharts from './components/HarmonyEcoCharts.vue';
import { wuhanGithubProjectsPage3 } from '@/api/jyh/situation';
const { widthType } = usePageResize(); const { widthType } = usePageResize();
const githubProjects = ref([ const githubProjects = ref([]);
// 武汉优质开源项目备用数据
const setgithubProjectsdata = () => {
githubProjects.value = [
{ {
name: 'bootstrap', name: 'bootstrap',
desc: 'The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.', desc: 'The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.',
@@ -365,7 +370,30 @@ const githubProjects = ref([
desc: '哔哩哔哩-API收集整理【不断更新中....】', desc: '哔哩哔哩-API收集整理【不断更新中....】',
stars: '20100' stars: '20100'
} }
]); ];
};
// 获取武汉优质开源项目数据
const fetchGithubProjects = async() => {
try {
const response = await wuhanGithubProjectsPage3();
const projectdata = response.data;
if (projectdata?.code === 200 && projectdata?.data) {
// 将星星数转换为字符串格式以匹配模板显示
const formattedData = projectdata.data.map(item => ({
...item,
stars: String(item.stars)
}));
githubProjects.value = formattedData;
} else {
console.error('获取武汉优质开源项目数据失败:', projectdata?.msg || '未知错误');
setgithubProjectsdata();
}
} catch (error) {
console.error('请求武汉优质开源项目数据时发生错误:', error);
setgithubProjectsdata();
}
};
const activeTab = ref(0); const activeTab = ref(0);
@@ -769,8 +797,9 @@ watch(widthType, () => {
init(); init();
}); });
onMounted(() => { onMounted(async () => {
init(); await fetchGithubProjects(); // 先获取数据
init(); // 再初始化图表
}); });
onUnmounted(() => { onUnmounted(() => {