From 9ce6bbe07f5ec3bfa997d36e8eb34bb6483911b1 Mon Sep 17 00:00:00 2001 From: d266377 Date: Wed, 4 Feb 2026 11:37:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=81=E5=8A=BF=E6=84=9F=E7=9F=A5=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0-=E6=AD=A6=E6=B1=89=E5=B8=82=E5=BC=80=E6=BA=90?= =?UTF-8?q?=E7=94=9F=E6=80=81=E5=BB=BA=E8=AE=BE-=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E6=95=B0=E9=87=8F=E6=8E=92=E8=A1=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Jyh/Community/index.vue | 53 ++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/views/Jyh/Community/index.vue b/src/views/Jyh/Community/index.vue index 715cbaa..671362e 100644 --- a/src/views/Jyh/Community/index.vue +++ b/src/views/Jyh/Community/index.vue @@ -311,12 +311,20 @@ import * as echarts from 'echarts'; import { usePageResize } from '@/utils/hooks/usePageResize'; import StatsBar from './components/StatsBar.vue'; import HarmonyEcoCharts from './components/HarmonyEcoCharts.vue'; -import { wuhanGithubProjectsPage3, cityProjectPage3, chinaExcellentProjectsPage3, excellentProjectsPage3, talentPage3, developerNamesPage3 } from '@/api/jyh/situation'; +import { wuhanGithubProjectsPage3, cityProjectPage3, chinaExcellentProjectsPage3, excellentProjectsPage3, talentPage3, developerNamesPage3, communityRankChartPage3 } from '@/api/jyh/situation'; const { widthType } = usePageResize(); const githubProjects = ref([]); +const activeTab = ref(0); + +const excellentProjects = ref([]); + +const chinaExcellentProjects = ref([]); + +const developerNames = ref([]); + // 武汉优质开源项目备用数据 const setgithubProjectsdata = () => { githubProjects.value = [ @@ -451,15 +459,33 @@ const fetchTalentData = async() => { } }; +// 城市社区数量排行备用数据 +const setCommunityRankDefaultData = () => { + chartData.value.communityRank.xAxis = ['北京', '深圳', '上海', '杭州', '广州', '成都', '南京', '武汉']; + chartData.value.communityRank.data = [69, 35, 31, 25, 18, 15, 12, 12]; + isEmpty.value.communityRank = false; +}; -const activeTab = ref(0); - -const excellentProjects = ref([]); - -const chinaExcellentProjects = ref([]); - -// 开发者名单 -const developerNames = ref([]); +// 获取武汉社区数量排行数据 +const fetchCommunityRankData = async() => { + try { + const response = await communityRankChartPage3(); + const communitydata = response.data; + if (communitydata?.code === 200 && communitydata?.data) { + // 更新图表数据 + chartData.value.communityRank.xAxis = communitydata.data.map(item => item.name); + chartData.value.communityRank.data = communitydata.data.map(item => item.value); + // 设置非空状态 + isEmpty.value.communityRank = false; + } else { + console.error('获取城市社区数量排行数据失败:', communitydata?.msg || '未知错误'); + setCommunityRankDefaultData(); + } + } catch (error) { + console.error('请求城市社区数量排行数据时发生错误:', error); + setCommunityRankDefaultData(); + } +}; // 2024武汉优秀开源项目备用数据 const chinaExcellentProjectsdata = () => { @@ -802,12 +828,14 @@ const initCommunityRankChart = () => { grid: { left: '3%', right: '4%', bottom: '15px', top: '22%', containLabel: true }, xAxis: { type: 'category', - data: ['北京', '深圳', '上海', '杭州', '广州', '成都', '南京', '武汉'], + data: chartData.value.communityRank.xAxis, axisLabel: { color: '#666' } }, - yAxis: { type: 'value', name: '单位:个', nameTextStyle: { color: '#999' } }, + yAxis: { type: 'value', name: '单位:个', nameTextStyle: { color: '#999' }}, series: [{ - type: 'bar', data: [69, 35, 31, 25, 18, 15, 12, 12], barWidth: '40%', + type: 'bar', + data: chartData.value.communityRank.data, + barWidth: '40%', itemStyle: { borderRadius: [4, 4, 0, 0], color: '#3b82f6' } }] }); @@ -929,6 +957,7 @@ onMounted(async() => { await fetchDeveloperNamesData(); // 获取武汉明星开发者贡献榜数据 await fetchchinaExcellentProjects(); // 获取2024中国优秀开源项目数据 await fetchexcellentProjects(); // 获取2025武汉优秀开源项目数据 + await fetchCommunityRankData(); // 获取城市社区数量排行数据 init(); // 再初始化图表 });