hookehuyr

feat(组件通信): 暴露FamilyAlbum刷新方法供父组件调用

在FamilyAlbum组件中通过defineExpose暴露refreshData方法
父组件Dashboard通过ref调用该方法刷新相册数据
...@@ -168,6 +168,11 @@ onMounted(() => { ...@@ -168,6 +168,11 @@ onMounted(() => {
168 useDidShow(() => { 168 useDidShow(() => {
169 fetchAlbumData(); 169 fetchAlbumData();
170 }); 170 });
171 +
172 +// 暴露刷新方法给父组件
173 +defineExpose({
174 + refreshData: fetchAlbumData,
175 +});
171 </script> 176 </script>
172 177
173 <style lang="less" scoped> 178 <style lang="less" scoped>
......
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
138 <RankingCard ref="rankingCardRef" :onViewMore="openFamilyRank" /> 138 <RankingCard ref="rankingCardRef" :onViewMore="openFamilyRank" />
139 139
140 <!-- Family album --> 140 <!-- Family album -->
141 - <FamilyAlbum /> 141 + <FamilyAlbum ref="familyAlbumRef" />
142 142
143 <BottomNav /> 143 <BottomNav />
144 144
...@@ -181,6 +181,7 @@ const rankingCardRef = ref(null) ...@@ -181,6 +181,7 @@ const rankingCardRef = ref(null)
181 const showTotalPointsOnly = ref(false) 181 const showTotalPointsOnly = ref(false)
182 const finalTotalPoints = ref(0) 182 const finalTotalPoints = ref(0)
183 const pendingPoints = ref([]) // 待收集的积分数据 183 const pendingPoints = ref([]) // 待收集的积分数据
184 +const familyAlbumRef = ref(null)
184 185
185 const familyName = ref('') 186 const familyName = ref('')
186 const familySlogn = ref('') 187 const familySlogn = ref('')
...@@ -331,7 +332,7 @@ const refreshDashboardData = async () => { ...@@ -331,7 +332,7 @@ const refreshDashboardData = async () => {
331 familyOwner.value = data.family.is_my; 332 familyOwner.value = data.family.is_my;
332 todaySteps.value = data.my_today_step; 333 todaySteps.value = data.my_today_step;
333 totalFamilySteps.value = data.family_today_step; 334 totalFamilySteps.value = data.family_today_step;
334 - 335 +
335 console.log('Dashboard页面数据刷新成功:', { 336 console.log('Dashboard页面数据刷新成功:', {
336 familyName: familyName.value, 337 familyName: familyName.value,
337 todaySteps: todaySteps.value, 338 todaySteps: todaySteps.value,
...@@ -350,7 +351,7 @@ const refreshDashboardData = async () => { ...@@ -350,7 +351,7 @@ const refreshDashboardData = async () => {
350 */ 351 */
351 useLoad(async () => { 352 useLoad(async () => {
352 console.log('Dashboard页面加载,开始静默授权'); 353 console.log('Dashboard页面加载,开始静默授权');
353 - 354 +
354 // 进行静默授权 355 // 进行静默授权
355 try { 356 try {
356 await silentAuth( 357 await silentAuth(
...@@ -382,6 +383,11 @@ useDidShow(async () => { ...@@ -382,6 +383,11 @@ useDidShow(async () => {
382 rankingCardRef.value.refreshData(); 383 rankingCardRef.value.refreshData();
383 } 384 }
384 385
386 + // 刷新相册数据
387 + if (familyAlbumRef.value) {
388 + familyAlbumRef.value.refreshData();
389 + }
390 +
385 // TODO: 获取广告信息 391 // TODO: 获取广告信息
386 adObj.value = { 392 adObj.value = {
387 adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg', 393 adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg',
......