1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-11-13 22:11:42 +08:00

refactor: 优化滚动监听逻辑与评论系统,新增对齐alova的meta参数

1. 重构usePageScroll hook,支持自定义默认滚动值并暴露更新方法
2. 全局页面统一接入onPageScroll监听,替换原有内置日志打印
3. 新增评论可见回复数、回复引用、分页回复加载等评论扩展能力
4. 调整全局操作按钮位置与部分UI样式细节
5. 优化请求拦截器,对齐alova参数格式重构query处理逻辑
6. 完善评论弹窗与评论列表组件,实现抖音式折叠回复交互
This commit is contained in:
小莫唐尼
2026-09-12 23:35:50 +08:00
parent e5e3ad3d8b
commit 1cb300f07a
36 changed files with 390 additions and 128 deletions
+6 -5
View File
@@ -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<IResponse<IPostListRes>>('/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<IResponse<IPostListRes>>(`/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<IResponse<ICommentListRes>>(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, {
return http.Get<IResponse<ICommentReplyListRes>>(`/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;
}
/**
+9
View File
@@ -235,6 +235,8 @@ export interface IComment {
status?: {
hasReply?: boolean
replyCount?: number
/** 可见回复数(公开接口按审核可见统计) */
visibleReplyCount?: number
visibleTime?: string
}
replies?: IListResult<ICommentReply>
@@ -264,12 +266,19 @@ export interface ICommentReply {
}
}
/** 评论回复列表响应(分页) */
export type ICommentReplyListRes = IListResult<ICommentReply>
export interface ICommentListReq {
page?: number
size?: number
sort?: string[]
/** 主题名称(文章 name) */
name?: string
/** 是否携带该评论的部分回复(默认 false) */
withReplies?: boolean
/** 携带回复条数(仅 withReplies=true 时生效,默认 10) */
replySize?: number
[key: string]: unknown
}
@@ -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<string, string>
}>(), {
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 @@
<view class="text-sm text-gray-500">
<text class="text-grey text-xs">{{ comment.spec.owner.displayName }}</text>
</view>
<view class="mt-0.5 box-border text-sm text-gray-900 leading-5" @click="handleOnDetail"
<view v-if="quoteReplyText" class="mt-1 text-xs text-gray-400">{{ quoteReplyText }}</view>
<view class="mt-0.5 box-border text-sm text-gray-900 leading-5" @click="handleOnDetail"
v-html="comment.spec.raw" />
<view class="mt-2 flex items-center gap-x-4">
<text class="text-gray-900 text-xs">{{ createTimeText }}</text>
<view v-if="useActions" class="actions flex gap-2 font-bold">
<view v-if="useActions" class="actions flex gap-2 font-medium">
<view v-if="!disallowComment" class="text-xs" @click="handleOnReply">
回复
</view>
@@ -1,8 +1,8 @@
<script lang="ts" setup>
import { onMounted, onUnmounted, ref } from 'vue'
import { getPostCommentList } from '@/api/halo'
import { onMounted, onUnmounted, reactive, ref } from 'vue'
import { getPostCommentList, getPostCommentReplyList } from '@/api/halo'
import { checkAvatarUrl } from '@/utils/url'
import type { IComment, ICommentListRes } from '@/api/types/halo'
import type { IComment, ICommentListRes, ICommentReply } from '@/api/types/halo'
const props = withDefaults(defineProps<{
disallowComment ?: boolean
@@ -16,7 +16,7 @@
})
const emit = defineEmits<{
(e : 'on-comment', data : { isComment : boolean, postName : string, title : string }) : void
(e : 'on-comment', data : { isComment : boolean, postName : string, title : string, quoteReply ?: string }) : void
(e : 'on-comment-detail', data : { postName : string, comment : IComment }) : void
(e : 'on-loaded', list : IComment[]) : void
}>()
@@ -29,12 +29,26 @@
name: props.postName,
page: 1,
size: 50,
withReplies: true,
replySize: 10,
})
const result = ref<ICommentListRes | null>(null)
const dataList = ref<IComment[]>([])
/** 回复按需加载每页条数(对齐官方 comment-widget replySize 默认 20) */
const REPLIES_PAGE_SIZE = 20
interface IRepliesState {
list : ICommentReply[]
total : number
page : number
hasNext : boolean
status : 'loading' | 'success' | 'error'
}
/** 已展开的评论 name 集合 */
const expanded = reactive(new Set<string>())
/** 各评论已加载回复(展开后缓存,收起再展开不重拉) */
const repliesMap = reactive(new Map<string, IRepliesState>())
async function handleGetData() {
loading.value = 'loading'
try {
@@ -45,6 +59,9 @@
item.spec.owner.avatar = checkAvatarUrl(item.spec.owner.avatar ?? 'https://api.dicebear.com/10.x/adventurer-neutral/svg')
return item
})
// 列表刷新后清空展开缓存,保证回复区展示最新数据
expanded.clear()
repliesMap.clear()
loading.value = 'success'
emit('on-loaded', dataList.value)
}
@@ -54,17 +71,97 @@
}
}
function handleToComment(data ?: { type : string, comment : IComment }) {
/** 回复数(优先可见数,兜底总回复数/内嵌 total) */
function getReplyCount(comment : IComment) : number {
return comment.status?.visibleReplyCount ?? comment.status?.replyCount ?? comment.replies?.total ?? 0
}
function getRepliesState(comment : IComment) : IRepliesState | undefined {
return repliesMap.get(comment.metadata.name)
}
/** 展开/收起某条评论的回复(首次展开时按需拉取) */
function toggleReplies(comment : IComment) {
const name = comment.metadata.name
if (expanded.has(name)) {
expanded.delete(name)
return
}
expanded.add(name)
if (!repliesMap.has(name)) {
loadReplies(comment)
}
}
/** 首次展开:拉取第一页回复 */
async function loadReplies(comment : IComment) {
const name = comment.metadata.name
if (!repliesMap.has(name)) {
repliesMap.set(name, { list: [], total: 0, page: 0, hasNext: false, status: 'loading' })
}
const state = repliesMap.get(name)!
state.status = 'loading'
try {
const res = await getPostCommentReplyList(name, { page: 1, size: REPLIES_PAGE_SIZE })
const data = res.data
state.list = data.items
state.total = data.total
state.page = data.page
state.hasNext = data.hasNext
state.status = 'success'
}
catch (err) {
console.error('获取回复失败', err)
state.status = 'error'
}
}
/** 加载更多回复(追加下一页) */
async function loadMoreReplies(comment : IComment) {
const state = repliesMap.get(comment.metadata.name)
if (!state || state.status === 'loading')
return
state.status = 'loading'
try {
const res = await getPostCommentReplyList(comment.metadata.name, { page: state.page + 1, size: REPLIES_PAGE_SIZE })
const data = res.data
state.list = state.list.concat(data.items)
state.page = data.page
state.hasNext = data.hasNext
state.status = 'success'
}
catch (err) {
console.error('加载更多回复失败', err)
state.status = 'error'
}
}
/** 已加载回复的 name -> displayName 映射(供「回复 @xxx」引用标识查询) */
function buildQuoteReplyMap(comment : IComment) : Record<string, string> {
const state = repliesMap.get(comment.metadata.name)
if (!state)
return {}
const map : Record<string, string> = {}
state.list.forEach((reply) => {
map[reply.metadata.name] = reply.spec.owner.displayName
})
return map
}
/** 回复/新增评论(data 有值=回复某条评论;parentComment=所属一级评论,回复接口需要其 name) */
function handleToComment(data ?: { type : string, comment : ICommentReply }, parentComment ?: IComment) {
if (props.disallowComment) {
uni.showToast({ icon: 'none', title: '文章已禁止评论!' })
return
}
if (data) {
// 回复某条评论
if (data && parentComment) {
// 回复:postName 必须是一级评论(Comment)的 name;回复二级评论时带 quoteReply 引用其 name
const isQuote = data.comment.metadata.name !== parentComment.metadata.name
emit('on-comment', {
isComment: false,
postName: data.comment.metadata.name,
postName: parentComment.metadata.name,
title: data.comment.spec.owner.displayName,
quoteReply: isQuote ? data.comment.metadata.name : undefined,
})
}
else {
@@ -161,20 +258,55 @@
</view>
<block v-else>
<!-- 一级评论 -->
<!-- 一级评论 + 按需展开的回复区 -->
<template v-for="comment in dataList" :key="comment.metadata.name">
<uh-comment-item :use-content-bg="false" :is-child="false" :comment="comment"
:post-name="postName" :disallow-comment="disallowComment" @on-copy="handleCopyContent"
@on-comment="handleToComment" @on-detail="handleShowCommentDetail" />
@on-comment="(d) => handleToComment(d, comment)" @on-detail="handleShowCommentDetail" />
<!-- 二级评论 -->
<template v-if="comment.replies && comment.replies.items.length !== 0">
<uh-comment-item v-for="childComment in comment.replies.items"
:key="childComment.metadata.name" :use-content-bg="false" :is-child="true"
:comment="childComment" :post-name="postName" :disallow-comment="disallowComment"
@on-copy="handleCopyContent" @on-comment="handleToComment"
@on-detail="handleShowCommentDetail" />
</template>
<!-- 回复展开区(默认收起,抖音式) -->
<view v-if="getReplyCount(comment) > 0">
<!-- 未展开:仅显示回复数 -->
<view v-if="!expanded.has(comment.metadata.name)"
class="mt-2 ml-10 inline-flex items-center rounded-lg bg-gray-100 px-3 py-1 text-xs text-gray-500"
@click="toggleReplies(comment)">
共 {{ getReplyCount(comment) }} 条回复
</view>
<!-- 已展开:回复列表 -->
<block v-else>
<view v-if="getRepliesState(comment)?.status === 'error'"
class="mt-2 ml-10 text-xs text-red-400" @click="loadReplies(comment)">
回复加载失败,点击重试
</view>
<view v-else-if="getRepliesState(comment)?.status === 'loading' && getRepliesState(comment)?.list.length === 0"
class="mt-2 ml-10 text-xs text-gray-400">
回复加载中...
</view>
<template v-else>
<uh-comment-item v-for="childComment in getRepliesState(comment)?.list"
:key="childComment.metadata.name" :use-content-bg="false" :is-child="true"
:comment="childComment" :post-name="postName"
:disallow-comment="disallowComment"
:quote-reply-map="buildQuoteReplyMap(comment)"
@on-copy="handleCopyContent" @on-comment="(d) => handleToComment(d, comment)"
@on-detail="handleShowCommentDetail" />
<!-- 加载更多(响应 hasNext) -->
<view v-if="getRepliesState(comment)?.hasNext"
class="mt-2 flex items-center justify-center">
<text class="text-xs text-gray-400" @click="loadMoreReplies(comment)">
{{ getRepliesState(comment)?.status === 'loading' ? '加载中...' : '加载更多回复' }}
</text>
</view>
</template>
<!-- 收起 -->
<view class="mt-2 ml-10 text-xs text-gray-400" @click="toggleReplies(comment)">
收起回复
</view>
</block>
</view>
</template>
</block>
</block>
@@ -12,10 +12,13 @@
postName : string
/** 评论目标 kind(文章 Post / 瞬间 Moment) */
subjectKind ?: string
/** 回复的回复:被引用回复(CommentReply)的 name,提交时转 quoteReply */
quoteReply ?: string
}>(), {
isComment: false,
title: '',
subjectKind: 'Post',
quoteReply: '',
})
const emit = defineEmits<{
@@ -211,6 +214,7 @@
email: form.value.email,
website: form.value.authorUrl,
},
quoteReply: props.quoteReply || undefined,
captchaCode: config.value?.security?.captcha?.anonymousCommentCaptcha ? form.value.captchaCode : undefined,
})
uni.showToast({ icon: 'none', title: '回复成功,可能需要审核!' })
@@ -7,7 +7,7 @@
</script>
<template>
<view class="fixed right-3 bottom-22 z-50 flex flex-col gap-y-3 pb-safe">
<view class="fixed right-3 bottom-18 z-50 flex flex-col gap-y-3 pb-safe">
<slot></slot>
</view>
</template>
@@ -78,21 +78,23 @@
<template>
<uh-glass-popup v-model="isShow" position="center" :z-index="9999" custom-class="rounded-xl" @close="handleClose">
<view v-if="notice" class="box-border w-[80vw] p-4">
<!-- 头部:标题 + 关闭 -->
<view class="flex items-center justify-between">
<view class="flex items-center gap-2">
<wd-icon class-prefix="uhemoji2-icon" name="-happy-" size="36rpx" />
<text class="text-md font-semibold text-gray-900">
最新公告
</text>
<view v-if="notice.typeDisplayName" class="rounded px-1.5 py-0.5 text-xs" :style="{
color: notice.typeColor || '#f83856',
backgroundColor: notice.typeColor ? `${notice.typeColor}1a` : '#fdeef1',
<view v-if="notice.typeDisplayName" class="rounded px-1.5 py-0.5 text-xs text-primary bg-gray-100"
:style="{
color: notice.typeColor,
backgroundColor: notice.typeColor ? `${notice.typeColor}1a` : '',
}">
{{ notice.typeDisplayName }}
</view>
</view>
<view class="uh-global-card-glass !bg-white/5 border flex h-6 w-6 rounded-lg items-center justify-center text-gray-500" @click="handleClose">
<view
class="uh-global-card-glass !bg-white/5 border flex h-6 w-6 rounded-lg items-center justify-center text-gray-500"
@click="handleClose">
<wd-icon name="close" size="16px" />
</view>
</view>
@@ -101,13 +103,13 @@
<view class="mt-4">
<image v-if="notice.cover" :src="checkImageUrl(notice.cover)" class="w-full h-34 rounded-lg mb-2">
</image>
<view class="text-md font-bold leading-snug text-gray-900">
<view class="text-sm font-bold leading-snug text-gray-900">
{{ notice.title }}
</view>
<view v-if="notice.summary" class="mt-3 text-sm leading-relaxed text-gray-500">
<view v-if="notice.summary" class="mt-3 text-2xs leading-relaxed text-gray-600">
{{ notice.summary }}
</view>
<view v-if="notice.publishTime" class="mt-3 text-xs text-gray-400">
<view v-if="notice.publishTime" class="mt-3 text-xs text-gray-600">
日期:{{ formatDate(notice.publishTime) }}
</view>
</view>
+6 -8
View File
@@ -1,13 +1,11 @@
import { ref } from 'vue';
import { onPageScroll } from '@dcloudio/uni-app';
export function usePageScroll() {
const scrollY = ref(0);
export function usePageScroll(defaultScrollValue: number = 0) {
const scrollY = ref(defaultScrollValue);
onPageScroll((e: any) => {
scrollY.value = e.scrollTop;
console.log('滚动数据', scrollY.value);
});
function updatePageScrollValue(scrollValue: number) {
scrollY.value = scrollValue;
}
return { scrollY };
return { scrollY, updatePageScrollValue };
}
+4 -4
View File
@@ -17,10 +17,10 @@ const httpInterceptor = {
// 非 alova 请求,正常执行
// 接口请求支持通过 query 参数配置 queryString
console.log('==========options',options)
if (options.query) {
// const queryStr = qs.stringify(options.query, {
if (options?.meta?.query) {
// const queryStr = qs.stringify(options?.meta?.query, {
// allowDots: true,
// encodeValuesOnly: true,
// skipNulls: true,
@@ -28,7 +28,7 @@ const httpInterceptor = {
// arrayFormat: 'repeat'
// })
const queryStr = stringifyQuery(options.query)
const queryStr = stringifyQuery(options?.meta?.query)
if (options.url.includes('?')) {
options.url += `&${queryStr}`;
} else {
+2
View File
@@ -3,6 +3,8 @@
*/
export type CustomRequestOptions = UniApp.RequestOptions & {
query?: Record<string, any>
// 对标 alova 参数
meta?: Record<string, any>
/** 出错时是否隐藏错误提示 */
hideErrorToast?: boolean
} & IUniUploadFileOptions // 添加uni.uploadFile参数类型
+6 -2
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { checkUrl } from '@/utils/url'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -11,7 +11,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const appInfo = computed(() => {
@@ -39,6 +39,10 @@ const appConfigStore = useAppConfigStore()
})
}
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
uni.setNavigationBarTitle({ title: '关于项目' })
})
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getPostList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
@@ -17,7 +17,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -222,6 +222,10 @@ function handleToTopPage(duration = 500) {
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
handleGetData()
onPullDownRefresh(() => {
@@ -26,7 +26,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const favoritesStore = useFavoritesStore()
const settingStore = useSettingStore()
@@ -58,6 +58,7 @@
isComment: false,
postName: '',
title: '',
quoteReply: '',
})
const commentDetail = ref({
show: false,
@@ -78,6 +79,7 @@
}
})
const globalAppSettings = computed(() => settingStore.settings)
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
const calcIsShowComment = computed(() => !!postDetailConfig.value?.showComment)
const doubanPluginConfig = computed(() => (haloConfigs.value.pluginConfig?.doubanPlugin as { position ?: string } | undefined) || {})
@@ -194,7 +196,7 @@
const { hasUpvoted, handleDoLikes } = useUpvote('posts', () => result.value?.metadata.name)
function handleDoLikesClick() {
handleDoLikes((name) => {
handleDoLikes(() => {
if (result.value?.stats) {
result.value.stats.upvote = (result.value.stats.upvote || 0) + 1
}
@@ -314,15 +316,17 @@
isComment: true,
postName: result.value.metadata.name,
title: '新增评论',
quoteReply: '',
}
}
function handleOnComment(data : { isComment : boolean, postName : string, title : string }) {
function handleOnComment(data : { isComment : boolean, postName : string, title : string, quoteReply ?: string }) {
commentModal.value = {
show: true,
isComment: data.isComment,
postName: data.postName,
title: data.title,
quoteReply: data.quoteReply ?? '',
}
}
@@ -419,6 +423,10 @@
handleGetData()
})
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onPullDownRefresh(() => {
handleGetData()
})
@@ -440,12 +448,6 @@
imageUrl: cover,
}
})
const globalAppSettings = computed(() => settingStore.settings)
onPageScroll((e : any) => {
console.log('滚动', e)
})
</script>
<template>
@@ -470,11 +472,11 @@
boxShadow: '0 -16rpx 12rpx rgba(0, 0, 0, 0.035)',
}">
<!-- 顶部信息 -->
<view class="box-border flex flex-col gap-3 p-4 pb-2">
<view class="box-border flex flex-col gap-3 p-3 pb-2">
<view class="flex items-center gap-x-2">
<image :src="result.owner.avatar" class="uh-global-card-glass block h-6 w-6 rounded-full"
mode="aspectFill" />
<text class="text-sm font-semibold">{{ result?.owner?.displayName }}</text>
<text class="text-sm font-medium text-gray-600">{{ result?.owner?.displayName }}</text>
</view>
<view class="font-semibold">
{{ result?.spec.title }}
@@ -525,7 +527,7 @@
</view>
<!-- 内容区域 -->
<view class="box-border flex flex-col gap-y-3 p-4 pt-2 text-gray-900 text-3xs">
<view class="box-border flex flex-col gap-y-3 p-3 pt-2 text-gray-900 text-3xs">
<!-- 受限阅读 -->
<template v-if="checkPostRestrictRead(result!)">
<view v-if="showContentArr.length === 0">
@@ -590,7 +592,7 @@
</view>
<!-- 悬浮操作 -->
<view class="fixed bottom-4 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
<view class="fixed bottom-2 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
<view
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
<view
@@ -638,7 +640,8 @@
<!-- 评论弹窗 -->
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
:title="commentModal.title" :post-name="commentModal.postName" @on-close="handleOnCommentModalClose" />
:title="commentModal.title" :post-name="commentModal.postName" :quote-reply="commentModal.quoteReply"
@on-close="handleOnCommentModalClose" />
</view>
</template>
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getCategoryList, getCategoryPostList, getPostList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
@@ -18,7 +18,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -163,6 +163,10 @@ async function handleGetArticleList() {
}
}
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
handleGetCategoryList()
handleGetArticleList()
@@ -5,7 +5,7 @@
* 外链平台差异(条件编译):非 APP-PLUS(小程序/H5)提供复制链接,APP-PLUS 提供访问按钮(web-view)
*/
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
import { getBannerDetail } from '@/api/uni-halo'
import { checkAvatarUrl, checkThumbnailUrl } from '@/utils/url'
import { formatTime } from '@/utils/formatTime'
@@ -23,7 +23,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
const name = ref('')
const detail = ref<IBannerPublicDetail | null>(null)
@@ -74,6 +74,10 @@ async function loadDetail() {
}
}
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad((options) => {
name.value = options?.name || ''
loadDetail()
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { getCategoryPostList } from '@/api/halo'
import { sleep } from '@/utils/common'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
@@ -15,7 +15,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
const queryParams = ref({ size: 10, page: 0 })
const name = ref('')
@@ -96,6 +96,10 @@ function handleToArticleDetail(article: IPost) {
})
}
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad((options) => {
name.value = options?.name || ''
pageTitle.value = options?.title || '分类详情'
+6 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup>
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { onPageScroll } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -23,7 +24,7 @@ interface ISoical {
visible?: boolean
}
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
@@ -79,6 +80,10 @@ onUnmounted(() => {
clearInterval(clock)
}
})
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
</script>
<template>
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'
import { getChartData } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -17,7 +17,7 @@
})
/** 依赖插件(plugin-data-statistics,参考 gallery 对象传参模式) */
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const { pluginId, checking, tips, available: uniHaloPluginAvailable, check: checkPluginAvailable } = usePluginAvailable({
pluginId: NeedPluginIds.PluginDataStatistics,
tips: '阿偶,检测到当前插件没有安装或者启用,无法使用功能哦,请联系管理员',
@@ -159,6 +159,10 @@
handleGetData()
}
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onPullDownRefresh(() => {
if (!uniHaloPluginAvailable.value) {
uni.stopPullDownRefresh()
+6 -1
View File
@@ -3,6 +3,7 @@
* 免责声明页
*/
import { computed } from 'vue'
import { onPageScroll } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -13,7 +14,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -39,6 +40,10 @@
},
})
}
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
</script>
<template>
+7 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup>
import { computed, ref, watchEffect } from 'vue'
import { onPageScroll } from '@dcloudio/uni-app'
import { formatTime } from '@/utils/formatTime'
import { useFavoritesStore } from '@/store/favorites'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
@@ -13,7 +14,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const favoritesStore = useFavoritesStore()
/* ---------------- Tab(文章/瞬间) ---------------- */
@@ -67,6 +68,11 @@ function handleRemove(item: IFavoriteItem) {
/* ---------------- 空态文案 ---------------- */
const emptyText = computed(() => (activeKind.value === 'post' ? '还没有收藏文章' : '还没有收藏瞬间'))
/* ---------------- 滚动 ---------------- */
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
</script>
<template>
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref, watch } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getFriendLinkGroupList, getFriendLinkList } from '@/api/halo'
import { getMiniProgramLinkGroupedList } from '@/api/uni-halo'
import { useAppConfigStore } from '@/store/appConfig'
@@ -21,7 +21,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const settingStore = useSettingStore()
@@ -349,6 +349,10 @@ function handleSaveMiniProgramCode(link: IMiniProgramLink) {
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(async () => {
await Promise.all([
checkSitePluginAvailable(),
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import { getLoveAlbumByName, getLoveAlbums } from '@/api/uni-halo'
import { useAppConfigStore } from '@/store/appConfig'
@@ -20,7 +20,7 @@ definePage({
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const loveConfig = computed(() => appConfigStore.configs.loveConfig)
@@ -211,6 +211,10 @@ function handleToTopPage(duration = 500) {
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
handleRestoreUnlockedAlbums()
handleGetData()
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getLoveDailyItems } from '@/api/uni-halo'
import { handleLoveModuleLocked } from '@/utils/loveModuleToken'
import { checkImageUrl } from '@/utils/url'
@@ -17,7 +17,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
/* ---------------- 展示层类型 ---------------- */
/** 清单展示卡片(script 预处理后的干净展示数据) */
@@ -252,6 +252,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
handleGetList()
})
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, onBeforeUnmount, ref } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onShow } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
import { getPluginCaptcha, unlockLoveModule, type ICaptchaQuery, type IPluginCaptcha } from '@/api/uni-halo'
@@ -15,7 +15,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
/* ---------------- 恋爱配置 ---------------- */
@@ -205,6 +205,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
syncLoveConfigFromStore()
})
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import { getLoveStories } from '@/api/uni-halo'
import { handleLoveModuleLocked } from '@/utils/loveModuleToken'
@@ -19,7 +19,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
/* ---------------- 展示层类型 ---------------- */
@@ -226,6 +226,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
handleGetStories()
})
+13 -11
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { getMomentByName } from '@/api/halo'
import { useUpvote } from '@/hooks/useUpvote'
import { useAppConfigStore } from '@/store/appConfig'
@@ -23,7 +23,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const favoritesStore = useFavoritesStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -92,7 +92,7 @@
const res = await getMomentByName(queryName.value)
const card = buildMomentCard(res.data)
moment.value = card
// 对象无键视为空 → 空态(与原 useDataLoading 默认判空一致)
updateLoadingStatus(
Object.keys(card).length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success,
)
@@ -134,8 +134,7 @@
/** 切换收藏(收藏/取消),收藏时按当前详情内容生成快照入库 */
function handleToggleMomentFavorite() {
const card = moment.value
if (!card)
return
if (!card) { return }
const favorited = favoritesStore.toggle(buildMomentFavoriteItem(card))
uni.showToast({ icon: 'none', title: favorited ? '收藏成功' : '已取消收藏' })
}
@@ -158,6 +157,7 @@
isComment: false,
postName: '',
title: '',
quoteReply: '',
})
/** 评论列表组件实例(评论成功后刷新) */
const commentListRef = ref<{ refresh : () => void } | null>(null)
@@ -175,16 +175,18 @@
isComment: true,
postName: current.metadata.name,
title: '新增评论',
quoteReply: '',
}
}
/** 评论列表触发(回复某条评论/新增) */
function handleOnComment(data : { isComment : boolean, postName : string, title : string }) {
function handleOnComment(data : { isComment : boolean, postName : string, title : string, quoteReply ?: string }) {
commentModal.value = {
show: true,
isComment: data.isComment,
postName: data.postName,
title: data.title,
quoteReply: data.quoteReply ?? '',
}
}
@@ -249,6 +251,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad((options) => {
queryName.value = options?.name || ''
loadMoment()
@@ -270,10 +276,6 @@
title: moment.value?.owner?.displayName || '',
query: moment.value ? `name=${moment.value.metadata.name}` : '',
}))
onPageScroll((e : any) => {
console.log('滚动', e)
})
</script>
<template>
@@ -397,7 +399,7 @@
<!-- 评论弹窗 -->
<uh-comment-modal v-if="commentModal.show" :show="commentModal.show" :is-comment="commentModal.isComment"
:title="commentModal.title" :post-name="commentModal.postName" subject-kind="Moment"
@on-close="handleOnCommentModalClose" />
:quote-reply="commentModal.quoteReply" @on-close="handleOnCommentModalClose" />
</view>
</template>
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
import { getNoticeDetail } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -16,7 +16,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
const name = ref('')
const detail = ref<INoticeDetail | null>(null)
@@ -83,6 +83,10 @@
}
}
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad((options) => {
name.value = options?.name || ''
loadDetail()
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getNotices } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -16,7 +16,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const PAGE_SIZE = 100
/** 状态机:首屏/下拉刷新 loading、empty、error;触底加载失败仅提示,不切整页错误态 */
@@ -156,6 +156,10 @@
loadNotices(false)
}
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
loadNotices(true)
})
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getPostListByKeyword } from '@/api/halo'
import { sleep } from '@/utils/common'
import { useAppConfigStore } from '@/store/appConfig'
@@ -18,7 +18,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -158,6 +158,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(async () => {
await checkPluginAvailable()
if (!uniHaloPluginAvailable.value) {
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onPageScroll } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { useSettingStore } from '@/store/setting'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -15,7 +15,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const settingStore = useSettingStore()
const appConfigStore = useAppConfigStore()
@@ -33,6 +33,10 @@
} = usePreferenceRows()
/** 确保启动合并已执行(入口页未跑或 H5 直达时兜底) */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(() => {
if (!settingStore.siteDefaults) {
settingStore.applySiteDefaults(collectSiteDefaults(appConfigStore.configs))
+6 -1
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { onPageScroll } from '@dcloudio/uni-app'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -8,9 +9,13 @@
navigationStyle: 'custom',
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
setTimeout(() => {
updateLoadingStatus(DataLoadingStatusEnum.Success)
}, 3000)
+6 -7
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { getVoteDetail, submitVote } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -17,11 +17,10 @@ definePage({
})
/* ---------------- 状态 ---------------- */
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
const submitLoading = ref(false)
const pageTitle = ref('加载中...')
const safeAreaBottom = ref(24)
const name = ref('')
const detail = ref<unknown>(null)
const vote = ref<(IVote & {
@@ -235,12 +234,12 @@ async function handleSubmit() {
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad((options) => {
name.value = options?.name || ''
// #ifndef H5
const systemInfo = uni.getSystemInfoSync()
safeAreaBottom.value = systemInfo.safeAreaInsets?.bottom ? systemInfo.safeAreaInsets.bottom + 12 : 24
// #endif
handleGetData()
})
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getVoteList } from '@/api/uni-halo'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
@@ -19,7 +19,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -258,6 +258,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(async () => {
await checkPluginAvailable()
if (!uniHaloPluginAvailable.value) {
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getCategoryList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { checkThumbnailUrl } from '@/utils/url'
@@ -19,7 +19,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
@@ -138,6 +138,10 @@
handleInitPage()
})
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onPullDownRefresh(() => {
handleResetInit()
handleGetData()
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getPhotoGroupList, getPhotoListByGroupName } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
import { checkImageUrl } from '@/utils/url'
@@ -20,7 +20,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs)
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
@@ -167,6 +167,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(async () => {
// 检查插件可用性
await checkPluginAvailable()
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import { getMomentList } from '@/api/halo'
import { useAppConfigStore } from '@/store/appConfig'
@@ -26,7 +26,7 @@
},
})
const { scrollY } = usePageScroll()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const favoritesStore = useFavoritesStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -287,6 +287,10 @@
}
/* ---------------- 生命周期 ---------------- */
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onLoad(async () => {
uni.setNavigationBarTitle({ title: t('page.moments.title') })
await checkPluginAvailable()