From a86baa9641bf8ca40e04fdb4ffb693f3a1d6113a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= Date: Mon, 15 Jun 2026 18:53:48 +0800 Subject: [PATCH] feat(blog,comment): add post comment panel and optimize tips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增文章评论弹窗组件uh-post-comment-panel 2. 给文章详情页评论按钮绑定打开评论面板事件 3. 优化图片画廊和评论加载失败的提示文案与样式 4. 修复评论列表接口返回类型适配问题 --- src/api/halo-base/comment.ts | 5 +- .../post-detail/uh-post-comment-panel.vue | 88 +++++++++++++++++++ .../uh-gallery-panel/uh-gallery-panel.vue | 4 +- src/subpkg-blog/post-detail/post-detail.vue | 23 ++++- 4 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 src/components/post-detail/uh-post-comment-panel.vue diff --git a/src/api/halo-base/comment.ts b/src/api/halo-base/comment.ts index a91040a..1932762 100644 --- a/src/api/halo-base/comment.ts +++ b/src/api/halo-base/comment.ts @@ -1,5 +1,6 @@ import { http } from '@/http/alova' -import type { Comment, CommentV1alpha1PublicApiCreateComment1Request, CommentV1alpha1PublicApiCreateReply1Request, CommentV1alpha1PublicApiGetCommentRequest, CommentV1alpha1PublicApiListCommentRepliesRequest, CommentV1alpha1PublicApiListComments1Request, CommentVoList, CommentWithReplyVoList, Reply, ReplyVoList } from '@halo-dev/api-client' +import type { Comment, CommentV1alpha1PublicApiCreateComment1Request, CommentV1alpha1PublicApiCreateReply1Request, CommentV1alpha1PublicApiGetCommentRequest, CommentV1alpha1PublicApiListCommentRepliesRequest, CommentV1alpha1PublicApiListComments1Request, CommentVoList, CommentWithReplyVo, Reply, ReplyVoList } from '@halo-dev/api-client' +import type { IHaloListResponseBase } from '../types/halo' const EndpointBase = '/apis/api.halo.run/v1alpha1/comments' @@ -35,7 +36,7 @@ export function createReply(data: CommentV1alpha1PublicApiCreateReply1Request) { * @returns 获取评论列表响应参数 */ export function listComments(params: CommentV1alpha1PublicApiListComments1Request) { - return http.Get(`${EndpointBase}`, { + return http.Get>(`${EndpointBase}`, { params, meta: { isHalo: true, diff --git a/src/components/post-detail/uh-post-comment-panel.vue b/src/components/post-detail/uh-post-comment-panel.vue new file mode 100644 index 0000000..b579413 --- /dev/null +++ b/src/components/post-detail/uh-post-comment-panel.vue @@ -0,0 +1,88 @@ + + + diff --git a/src/components/uh-gallery-panel/uh-gallery-panel.vue b/src/components/uh-gallery-panel/uh-gallery-panel.vue index 9fcbf22..2712a88 100644 --- a/src/components/uh-gallery-panel/uh-gallery-panel.vue +++ b/src/components/uh-gallery-panel/uh-gallery-panel.vue @@ -90,8 +90,8 @@ function handlePreview(item: IPhoto) { - - 加载失败,点击刷新试试 + + 加载失败,点击重试 数据已全部加载 diff --git a/src/subpkg-blog/post-detail/post-detail.vue b/src/subpkg-blog/post-detail/post-detail.vue index 5a2d5c2..933085b 100644 --- a/src/subpkg-blog/post-detail/post-detail.vue +++ b/src/subpkg-blog/post-detail/post-detail.vue @@ -153,6 +153,24 @@ onShareAppMessage(() => { path: `/subpkg-blog/post-detail/post-detail?metadataName=${postName}`, } }) + +const commentPanel = reactive<{ + show: boolean + post: PostVo | undefined +}>({ + show: false, + post: undefined, +}) + +function handleOpenCommentPanel(post: PostVo) { + commentPanel.show = true + commentPanel.post = post +} + +function handleCloseCommentPanel() { + commentPanel.show = false + commentPanel.post = undefined +}