diff --git a/web/src/components/comment-item.vue b/web/src/components/comment-item.vue index 677dbeea..4d0834c0 100644 --- a/web/src/components/comment-item.vue +++ b/web/src/components/comment-item.vue @@ -25,12 +25,6 @@
{{ comment.ip_loc}} -
+ + + + {{ thumbsUpCount }} +
+
+ + + + + {{ thumbsUpCount }} +
+
- - + - 1000
- - + +
@@ -73,8 +92,10 @@ import { ThumbDownOutlined, } from '@vicons/material'; -const hasUpvote = ref(false) -const hasDownvote = ref(true) +const hasThumbsUp = ref(false) +const hasThumbsDown = ref(false) +const thumbsUpCount = ref(0) + const props = withDefaults(defineProps<{ timestamp: number, commentId: number, @@ -95,6 +116,27 @@ const inputInstRef = ref(); const showReply = ref(false); const replyContent = ref(''); const submitting = ref(false); + +const handleThumbsUp = () => { + // TODO + hasThumbsUp.value = !hasThumbsUp.value + if (hasThumbsUp.value) { + thumbsUpCount.value++ + hasThumbsDown.value = false + } else { + thumbsUpCount.value-- + } +}; +const handleThumbsDown = () => { + // TODO + hasThumbsDown.value = !hasThumbsDown.value + if (hasThumbsDown.value) { + if (hasThumbsUp.value) { + thumbsUpCount.value-- + hasThumbsUp.value = false + } + } +}; const switchReply = (status: boolean) => { showReply.value = status; diff --git a/web/src/components/reply-item.vue b/web/src/components/reply-item.vue index 92662e36..8795edd6 100644 --- a/web/src/components/reply-item.vue +++ b/web/src/components/reply-item.vue @@ -28,12 +28,6 @@
{{ props.reply.ip_loc }} - - + + + + {{ thumbsUpCount }} +
+
+ + + + + {{ thumbsUpCount }} +
+
- - + - 100
- - + +
- 回复 + 回复 @@ -101,8 +115,9 @@ import { ThumbDownOutlined, } from '@vicons/material'; -const hasUpvote = ref(true) -const hasDownvote = ref(false) +const hasThumbsUp = ref(false) +const hasThumbsDown = ref(false) +const thumbsUpCount = ref(0) const props = withDefaults(defineProps<{ reply: Item.ReplyProps, @@ -113,6 +128,26 @@ const emit = defineEmits<{ (e: 'reload'): void }>(); +const handleThumbsUp = () => { + // TODO + hasThumbsUp.value = !hasThumbsUp.value + if (hasThumbsUp.value) { + thumbsUpCount.value++ + hasThumbsDown.value = false + } else { + thumbsUpCount.value-- + } +}; +const handleThumbsDown = () => { + // TODO + hasThumbsDown.value = !hasThumbsDown.value + if (hasThumbsDown.value) { + if (hasThumbsUp.value) { + thumbsUpCount.value-- + hasThumbsUp.value = false + } + } +}; const focusReply = () => { emit('focusReply', props.reply); }; @@ -159,8 +194,6 @@ const execDelAction = () => { .timestamp { opacity: 0.75; text-align: right; - display: flex; - align-items: center; max-width: 50%; overflow: hidden; text-overflow: ellipsis;