fix: 添加 onActivated 钩子以刷新帖子和评论

This commit is contained in:
CH-122
2025-08-19 16:51:22 +08:00
parent 5ebe739917
commit 27393c15f2

View File

@@ -166,7 +166,7 @@
</template>
<script setup>
import { ref, computed, onMounted, onBeforeUnmount, nextTick, watch, watchEffect } from 'vue'
import { ref, computed, onMounted, onBeforeUnmount, nextTick, watch, watchEffect, onActivated } from 'vue'
import VueEasyLightbox from 'vue-easy-lightbox'
import { useRoute } from 'vue-router'
import CommentItem from '~/components/CommentItem.vue'
@@ -746,6 +746,11 @@ const gotoProfile = () => {
navigateTo(`/users/${author.value.id}`, { replace: true })
}
onActivated(async () => {
await refreshPost()
await fetchComments()
})
onMounted(async () => {
await fetchComments()
const hash = location.hash