From 1cb300f07a7521063792d5a7c3bbd77a69ad1ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= Date: Sat, 12 Sep 2026 23:35:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E7=9B=91=E5=90=AC=E9=80=BB=E8=BE=91=E4=B8=8E=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E7=B3=BB=E7=BB=9F=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=AF=B9?= =?UTF-8?q?=E9=BD=90alova=E7=9A=84meta=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 重构usePageScroll hook,支持自定义默认滚动值并暴露更新方法 2. 全局页面统一接入onPageScroll监听,替换原有内置日志打印 3. 新增评论可见回复数、回复引用、分页回复加载等评论扩展能力 4. 调整全局操作按钮位置与部分UI样式细节 5. 优化请求拦截器,对齐alova参数格式重构query处理逻辑 6. 完善评论弹窗与评论列表组件,实现抖音式折叠回复交互 --- src/api/halo.ts | 11 +- src/api/types/halo.ts | 9 + .../uh-comment-item/uh-comment-item.vue | 25 ++- .../uh-comment-list/uh-comment-list.vue | 174 +++++++++++++++--- .../uh-comment-modal/uh-comment-modal.vue | 4 + .../uh-global-actions/uh-global-actions.vue | 2 +- .../uh-notify-dialog/uh-notify-dialog.vue | 18 +- src/hooks/usePageScroll.ts | 14 +- src/http/interceptor.ts | 8 +- src/http/types.ts | 2 + src/pages-blog/about/about.vue | 8 +- src/pages-blog/archives/archives.vue | 8 +- .../article-detail/article-detail.vue | 31 ++-- src/pages-blog/articles/articles.vue | 8 +- .../banner-detail/banner-detail.vue | 8 +- .../category-articles/category-articles.vue | 8 +- src/pages-blog/contact/contact.vue | 7 +- src/pages-blog/data-visual/data-visual.vue | 8 +- src/pages-blog/disclaimers/disclaimers.vue | 7 +- src/pages-blog/favorites/favorites.vue | 8 +- src/pages-blog/friend-links/friend-links.vue | 8 +- src/pages-blog/love/album.vue | 8 +- src/pages-blog/love/list.vue | 8 +- src/pages-blog/love/love.vue | 8 +- src/pages-blog/love/stories.vue | 8 +- .../moment-detail/moment-detail.vue | 26 +-- src/pages-blog/notice/detail.vue | 8 +- src/pages-blog/notice/notice.vue | 8 +- src/pages-blog/search/search.vue | 8 +- src/pages-blog/setting/setting.vue | 8 +- src/pages-blog/test/test.vue | 7 +- src/pages-blog/vote-detail/vote-detail.vue | 13 +- src/pages-blog/votes/votes.vue | 8 +- src/pages/tabbar/category/category.vue | 8 +- src/pages/tabbar/gallery/gallery.vue | 8 +- src/pages/tabbar/moments/moments.vue | 8 +- 36 files changed, 390 insertions(+), 128 deletions(-) diff --git a/src/api/halo.ts b/src/api/halo.ts index 4a0af96..0b434c8 100644 --- a/src/api/halo.ts +++ b/src/api/halo.ts @@ -14,6 +14,7 @@ import type { IComment, ICommentListReq, ICommentListRes, + ICommentReplyListRes, ILink, ILinkGroup, ILinkListRes, @@ -44,9 +45,8 @@ const COMMENT_WIDGET_CAPTCHA_COOKIES = 'comment-widget-captcha'; */ export function getPostList(params: IPostListReq) { return http.Get>('/apis/api.content.halo.run/v1alpha1/posts', { - query: params, cacheFor: 0, - meta: { requestFrom: RequestFrom.Halo } + meta: { requestFrom: RequestFrom.Halo, query: params } }); } @@ -92,9 +92,8 @@ export function getCategoryList(params: ICategoryListReq) { */ export function getCategoryPostList(name: string, params: IPostListReq) { return http.Get>(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, { - query: params, cacheFor: 0, - meta: { requestFrom: RequestFrom.Halo } + meta: { requestFrom: RequestFrom.Halo, query: params } }); } @@ -137,7 +136,7 @@ export function getPostCommentList(params: ICommentListReq) { * 评论回复列表 */ export function getPostCommentReplyList(commentName: string, params: ICommentListReq) { - return http.Get>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, { + return http.Get>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, { params, cacheFor: 0, meta: { requestFrom: RequestFrom.Halo } @@ -159,6 +158,8 @@ export interface IAddCommentReq { }; /** 验证码,提交时转入 X-Captcha-Code 头 */ captchaCode?: string; + /** 回复的回复:被引用回复(CommentReply)的 name */ + quoteReply?: string; } /** diff --git a/src/api/types/halo.ts b/src/api/types/halo.ts index e4a2bf4..49af333 100644 --- a/src/api/types/halo.ts +++ b/src/api/types/halo.ts @@ -235,6 +235,8 @@ export interface IComment { status?: { hasReply?: boolean replyCount?: number + /** 可见回复数(公开接口按审核可见统计) */ + visibleReplyCount?: number visibleTime?: string } replies?: IListResult @@ -264,12 +266,19 @@ export interface ICommentReply { } } +/** 评论回复列表响应(分页) */ +export type ICommentReplyListRes = IListResult + export interface ICommentListReq { page?: number size?: number sort?: string[] /** 主题名称(文章 name) */ name?: string + /** 是否携带该评论的部分回复(默认 false) */ + withReplies?: boolean + /** 携带回复条数(仅 withReplies=true 时生效,默认 10) */ + replySize?: number [key: string]: unknown } diff --git a/src/components/uh-comment-item/uh-comment-item.vue b/src/components/uh-comment-item/uh-comment-item.vue index 7786acc..18918c0 100644 --- a/src/components/uh-comment-item/uh-comment-item.vue +++ b/src/components/uh-comment-item/uh-comment-item.vue @@ -4,10 +4,10 @@ import relativeTime from 'dayjs/plugin/relativeTime' import { checkAvatarUrl } from '@/utils/url' import { useSettingStore } from '@/store/setting' - import type { IComment } from '@/api/types/halo' + import type { ICommentReply } from '@/api/types/halo' const props = withDefaults(defineProps<{ - comment : IComment + comment : ICommentReply isChild ?: boolean useActions ?: boolean useSolid ?: boolean @@ -15,6 +15,8 @@ disallowComment ?: boolean postName ?: string classItem ?: string[] + /** 回复引用名映射(quoteReply name -> 被引用人 displayName),命中时显示「回复 @xxx」 */ + quoteReplyMap ?: Record }>(), { isChild: false, useActions: true, @@ -23,11 +25,12 @@ disallowComment: false, postName: '', classItem: () => [], + quoteReplyMap: () => ({}), }) const emit = defineEmits<{ - (e : 'on-comment', data : { type : string, comment : IComment }) : void + (e : 'on-comment', data : { type : string, comment : ICommentReply }) : void (e : 'on-copy', raw : string) : void - (e : 'on-detail', comment : IComment) : void + (e : 'on-detail', comment : ICommentReply) : void }>() dayjs.extend(relativeTime) dayjs.locale('zh-cn') @@ -37,6 +40,15 @@ const avatar = computed(() => checkAvatarUrl(props.comment.spec.owner.avatar)) + /** 引用回复标识(被引用人在父级已加载回复映射中可查到时显示) */ + const quoteReplyText = computed(() => { + const quoteName = props.comment.spec.quoteReply + if (!quoteName) + return '' + const displayName = props.quoteReplyMap[quoteName] + return displayName ? `回复 @${displayName}` : '' + }) + /** 评论时间 */ const createTimeText = computed(() => { const time = props.comment.spec.creationTime @@ -77,11 +89,12 @@ {{ comment.spec.owner.displayName }} - {{ quoteReplyText }} + {{ createTimeText }} - + 回复 diff --git a/src/components/uh-comment-list/uh-comment-list.vue b/src/components/uh-comment-list/uh-comment-list.vue index a22de15..8540ea5 100644 --- a/src/components/uh-comment-list/uh-comment-list.vue +++ b/src/components/uh-comment-list/uh-comment-list.vue @@ -1,8 +1,8 @@ diff --git a/src/components/uh-notify-dialog/uh-notify-dialog.vue b/src/components/uh-notify-dialog/uh-notify-dialog.vue index 5089c21..0e7ce42 100644 --- a/src/components/uh-notify-dialog/uh-notify-dialog.vue +++ b/src/components/uh-notify-dialog/uh-notify-dialog.vue @@ -78,21 +78,23 @@