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 -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()
})
+14 -12
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)
@@ -91,8 +91,8 @@
try {
const res = await getMomentByName(queryName.value)
const card = buildMomentCard(res.data)
moment.value = card
// 对象无键视为空 → 空态(与原 useDataLoading 默认判空一致)
moment.value = card
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) {