From e9e996f291f37c842469da3dc126ba754123c54d Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Wed, 15 Oct 2025 17:47:45 +0800 Subject: [PATCH 1/8] refactor: simplify reactions group usage --- frontend_nuxt/components/CommentItem.vue | 89 +++++++++++++-- frontend_nuxt/components/ReactionsGroup.vue | 50 +-------- frontend_nuxt/pages/message-box/[id].vue | 116 +++++++++++++++++--- frontend_nuxt/pages/posts/[id]/index.vue | 95 +++++++++++----- 4 files changed, 257 insertions(+), 93 deletions(-) diff --git a/frontend_nuxt/components/CommentItem.vue b/frontend_nuxt/components/CommentItem.vue index b47456dda..4c260fd5a 100644 --- a/frontend_nuxt/components/CommentItem.vue +++ b/frontend_nuxt/components/CommentItem.vue @@ -53,14 +53,29 @@ @click="handleContentClick" >
- -
+ +
+ +
-
authState.loggedIn) +const commentReactionsGroupRef = ref(null) +const commentLikeCount = computed( + () => (props.comment.reactions || []).filter((reaction) => reaction.type === 'LIKE').length, +) +const commentLikedByMe = computed(() => + (props.comment.reactions || []).some( + (reaction) => reaction.type === 'LIKE' && reaction.user === authState.username, + ), +) +const toggleCommentLike = () => { + commentReactionsGroupRef.value?.toggleReaction('LIKE') +} const countReplies = (list) => list.reduce((sum, r) => sum + 1 + countReplies(r.reply || []), 0) const replyCount = computed(() => countReplies(props.comment.reply || [])) const isCommentFromPostAuthor = computed(() => { @@ -365,6 +392,56 @@ const handleContentClick = (e) => { diff --git a/frontend_nuxt/components/DonateGroup.vue b/frontend_nuxt/components/DonateGroup.vue new file mode 100644 index 000000000..00543f72c --- /dev/null +++ b/frontend_nuxt/components/DonateGroup.vue @@ -0,0 +1,126 @@ + + + + + diff --git a/frontend_nuxt/components/ReactionsGroup.vue b/frontend_nuxt/components/ReactionsGroup.vue index 122e6557a..e78a99049 100644 --- a/frontend_nuxt/components/ReactionsGroup.vue +++ b/frontend_nuxt/components/ReactionsGroup.vue @@ -164,7 +164,7 @@ const updatePanelInlineStyle = () => { if (!panelVisible.value) return const panelEl = reactionsPanelRef.value if (!panelEl) return - const parentEl = panelEl.closest('.reactions-container')?.parentElement + const parentEl = panelEl.closest('.reactions-container')?.parentElement?.parentElement if (!parentEl) return const parentWidth = parentEl.clientWidth - 20 panelInlineStyle.value = { @@ -357,7 +357,6 @@ onBeforeUnmount(() => { border: 1px solid var(--normal-border-color); border-radius: 10px; margin-right: 5px; - margin-bottom: 5px; font-size: 14px; color: var(--text-color); align-items: center; diff --git a/frontend_nuxt/pages/posts/[id]/index.vue b/frontend_nuxt/pages/posts/[id]/index.vue index ba0c7207f..e0dea1d71 100644 --- a/frontend_nuxt/pages/posts/[id]/index.vue +++ b/frontend_nuxt/pages/posts/[id]/index.vue @@ -92,12 +92,15 @@ >