fix: FavoritesPop cannot refresh data (#65)

This commit is contained in:
Hakadao
2023-11-08 01:31:13 +08:00
parent 268206f010
commit a5bab3f06c
2 changed files with 15 additions and 7 deletions

View File

@@ -64,12 +64,16 @@ watch(
},
)
// watch(showFavoritesPop, (newVal, oldVal) => {
// if (newVal === oldVal)
// return
// if (newVal && favoritesPopRef.value)
// favoritesPopRef.value.refreshFavoriteResources()
// })
watch(showFavoritesPop, (newVal, oldVal) => {
if (newVal === oldVal)
return
if (newVal) {
nextTick(() => {
if (favoritesPopRef.value)
favoritesPopRef.value.refreshFavoriteResources()
})
}
})
onMounted(() => {
initData()
@@ -370,7 +374,6 @@ async function getTopbarNewMomentsCount() {
<!-- Favorites -->
<div
ref="favoritesPopRef"
class="right-side-item"
:class="{ active: showFavoritesPop }"
@mouseenter="showFavoritesPop = true"
@@ -388,6 +391,7 @@ async function getTopbarNewMomentsCount() {
<KeepAlive>
<FavoritesPop
v-if="showFavoritesPop"
ref="favoritesPopRef"
class="bew-popover"
/>
</KeepAlive>

View File

@@ -117,6 +117,10 @@ function changeCategory(categoryItem: FavoriteCategory) {
activatedMediaId.value = categoryItem.id
activatedFavoriteTitle.value = categoryItem.title
}
defineExpose({
refreshFavoriteResources,
})
</script>
<template>