mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 11:06:23 +00:00
✨ feat: 添加评论动画样式和登录组件
This commit is contained in:
@ -36,6 +36,7 @@ export function CommentItem(
|
|||||||
|
|
||||||
const [likeCount, setLikeCount] = useState(comment.likeCount);
|
const [likeCount, setLikeCount] = useState(comment.likeCount);
|
||||||
const [liked, setLiked] = useState(comment.isLiked);
|
const [liked, setLiked] = useState(comment.isLiked);
|
||||||
|
const [canClickLike, setCanClickLike] = useState(true);
|
||||||
const [isPrivate, setIsPrivate] = useState(comment.isPrivate);
|
const [isPrivate, setIsPrivate] = useState(comment.isPrivate);
|
||||||
const [replyCount, setReplyCount] = useState(comment.replyCount);
|
const [replyCount, setReplyCount] = useState(comment.replyCount);
|
||||||
const [showReplies, setShowReplies] = useState(false);
|
const [showReplies, setShowReplies] = useState(false);
|
||||||
@ -45,6 +46,10 @@ export function CommentItem(
|
|||||||
const [showEditInput, setShowEditInput] = useState(false);
|
const [showEditInput, setShowEditInput] = useState(false);
|
||||||
|
|
||||||
const handleToggleLike = () => {
|
const handleToggleLike = () => {
|
||||||
|
if (!canClickLike) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setCanClickLike(false);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
toast.error(t("login_required"), {
|
toast.error(t("login_required"), {
|
||||||
action: <div className="flex justify-end">
|
action: <div className="flex justify-end">
|
||||||
@ -58,6 +63,7 @@ export function CommentItem(
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setLiked(!liked) // 提前转换状态,让用户觉得响应很快
|
||||||
toggleLike(
|
toggleLike(
|
||||||
{ targetType: TargetType.Comment, targetId: comment.id }
|
{ targetType: TargetType.Comment, targetId: comment.id }
|
||||||
).then(res => {
|
).then(res => {
|
||||||
@ -67,6 +73,7 @@ export function CommentItem(
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
toast.error(t("like_failed") + ": " + error.message);
|
toast.error(t("like_failed") + ": " + error.message);
|
||||||
});
|
});
|
||||||
|
setCanClickLike(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const reloadReplies = () => {
|
const reloadReplies = () => {
|
||||||
|
Reference in New Issue
Block a user