实现博客评论用户提示

This commit is contained in:
2025-06-19 15:16:55 +08:00
parent cb2258aa64
commit c782145e7e

View File

@@ -3,13 +3,16 @@ import { BlogCommentTool } from "./BlogCommentTool";
import { BlogApi } from "@/lib/api";
import { BlogComment } from "@/lib/types/blogComment";
import { useState } from "react";
import { useUserMe } from "@/hooks/user/use-user-me";
export function BlogComments({ blogId }: { blogId: string }) {
const { data, isLoading, error, mutate } = useSWR(
const { data, mutate } = useSWR(
`/api/blog/${blogId}/comments`,
() => BlogApi.getComments(blogId),
)
const { user } = useUserMe();
const insertComment = async (newOne: BlogComment) => {
await mutate(
(comments) => {
@@ -32,6 +35,13 @@ export function BlogComments({ blogId }: { blogId: string }) {
replayTarget={replayTarget}
handleClearReplayTarget={() => setReplayTarget(null)}
/>
<div className="text-sm text-zinc-600">
{
user ? (<span>{user.nickname}</span>) : (<span></span>)
}
</div>
<div className="flex flex-col">
{
data.filter(d => !d.parentId)