From 1e366af3b8a69104d7c17fe44ff0a00eca2db687 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 4 Mar 2024 22:13:25 +0800 Subject: [PATCH] :sparkles: Reactions --- pkg/views/src/components/posts/PostItem.vue | 24 +++++- pkg/views/src/components/posts/PostList.vue | 11 ++- .../src/components/posts/PostReaction.vue | 81 +++++++++++++++++++ pkg/views/src/views/explore.vue | 2 +- pkg/views/src/views/posts/details.vue | 19 ++++- 5 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 pkg/views/src/components/posts/PostReaction.vue diff --git a/pkg/views/src/components/posts/PostItem.vue b/pkg/views/src/components/posts/PostItem.vue index 66d37cc..a1fd23d 100644 --- a/pkg/views/src/components/posts/PostItem.vue +++ b/pkg/views/src/components/posts/PostItem.vue @@ -14,9 +14,19 @@
{{ props.item?.author.nick }}
-
Published an article
+
Published an + article +
+ +
@@ -27,13 +37,25 @@ import type { Component } from "vue"; import ArticleContent from "@/components/posts/ArticleContent.vue"; import MomentContent from "@/components/posts/MomentContent.vue"; +import PostReaction from "@/components/posts/PostReaction.vue"; const props = defineProps<{ item: any, brief?: boolean, loading?: boolean }>(); +const emits = defineEmits(["update:item"]); const renderer: { [id: string]: Component } = { article: ArticleContent, moment: MomentContent }; + +function updateReactions(symbol: string, num: number) { + const item = JSON.parse(JSON.stringify(props.item)); + if (item.reaction_list.hasOwnProperty(symbol)) { + item.reaction_list[symbol] += num; + } else { + item.reaction_list[symbol] = num; + } + emits("update:item", item); +}