hookehuyr

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

在FamilyAlbum组件中通过defineExpose暴露refreshData方法
父组件Dashboard通过ref调用该方法刷新相册数据
......@@ -168,6 +168,11 @@ onMounted(() => {
useDidShow(() => {
fetchAlbumData();
});
// 暴露刷新方法给父组件
defineExpose({
refreshData: fetchAlbumData,
});
</script>
<style lang="less" scoped>
......
......@@ -138,7 +138,7 @@
<RankingCard ref="rankingCardRef" :onViewMore="openFamilyRank" />
<!-- Family album -->
<FamilyAlbum />
<FamilyAlbum ref="familyAlbumRef" />
<BottomNav />
......@@ -181,6 +181,7 @@ const rankingCardRef = ref(null)
const showTotalPointsOnly = ref(false)
const finalTotalPoints = ref(0)
const pendingPoints = ref([]) // 待收集的积分数据
const familyAlbumRef = ref(null)
const familyName = ref('')
const familySlogn = ref('')
......@@ -331,7 +332,7 @@ const refreshDashboardData = async () => {
familyOwner.value = data.family.is_my;
todaySteps.value = data.my_today_step;
totalFamilySteps.value = data.family_today_step;
console.log('Dashboard页面数据刷新成功:', {
familyName: familyName.value,
todaySteps: todaySteps.value,
......@@ -350,7 +351,7 @@ const refreshDashboardData = async () => {
*/
useLoad(async () => {
console.log('Dashboard页面加载,开始静默授权');
// 进行静默授权
try {
await silentAuth(
......@@ -382,6 +383,11 @@ useDidShow(async () => {
rankingCardRef.value.refreshData();
}
// 刷新相册数据
if (familyAlbumRef.value) {
familyAlbumRef.value.refreshData();
}
// TODO: 获取广告信息
adObj.value = {
adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg',
......