Skip to content

Commit

Permalink
feat: 修复点赞逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Feb 18, 2023
1 parent b9bd8c6 commit afe8425
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Binary file modified backend/.tmp/data.db
Binary file not shown.
15 changes: 9 additions & 6 deletions frontend/components/ArticlesContent/SideBar/Left/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<script setup lang="ts">
defineProps<{
commented: Number
liked: Number
}>()
<script setup>
defineProps({
commented: {
type: Number,
},
liked: {
type: Number,
},
})
const isLiked = shallowRef(false)
const route = useRoute()
const url = shallowRef(`/api/articles/update/like?id=${route.params.id}`)
Expand All @@ -19,7 +23,6 @@ const handleLike = async () => {
}
}
}
const { immerseState, immerseToggle } = useImmerse()
</script>

Expand Down
3 changes: 2 additions & 1 deletion frontend/server/api/articles/update/like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export default defineEventHandler(async (event): Promise<liked> => {
}
}`
const articleData = (await useGraphql(reqQuery)).article
articleData.liked++
await useGraphql(`mutation updateArticle {
updateArticle(id: ${id}, data: { liked: ${++articleData.liked} }) {
updateArticle(id: ${id}, data: { liked: ${articleData.liked} }) {
data {
id
attributes {
Expand Down

0 comments on commit afe8425

Please sign in to comment.