mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
fix: 修复自定义导航栏吸顶布局偏移问题
1. 调整useCustomNavbarPlaceholder计算逻辑,仅H5平台额外添加10px偏移 2. 统一多个页面的吸顶导航样式,优化间距和文字大小 3. 为所有使用wd-sticky的页面添加正确的offsetTop参数 4. 重构文章列表页面代码结构,统一代码风格
This commit is contained in:
@@ -10,12 +10,13 @@ export function useCustomNavbarPlaceholder(customNavbarHeight?: number) {
|
||||
const winInfo = uni.getWindowInfo();
|
||||
const safeAreaTop = winInfo.safeArea.top;
|
||||
|
||||
height.value += safeAreaTop + 10;
|
||||
height.value += safeAreaTop;
|
||||
// #ifdef H5
|
||||
height.value += 10;
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
height.value += customNavbarHeight ?? 46;
|
||||
// #endif
|
||||
|
||||
console.log('最终高度', height.value);
|
||||
}
|
||||
|
||||
onMounted(init);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { useAppConfigStore } from '@/store/appConfig'
|
||||
import { useSettingStore } from '@/store/setting'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { sleep } from '@/utils/common'
|
||||
import type { IPost } from '@/api/types/halo'
|
||||
@@ -17,6 +18,7 @@
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const appConfigStore = useAppConfigStore()
|
||||
|
||||
@@ -259,15 +261,13 @@
|
||||
<view class="min-h-screen w-screen flex flex-col bg-page">
|
||||
<uh-navbar :scroll-y="scrollY" default-title="内容归档" title-color="text-gray-900" />
|
||||
|
||||
<wd-sticky>
|
||||
<scroll-view scroll-x class="w-full whitespace-nowrap">
|
||||
<view class="box-border flex gap-2 px-3 pb-1">
|
||||
<view v-for="(tab, index) in archiveTabs" :key="tab.key"
|
||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-5 py-2 text-2xs"
|
||||
:class="activeTabIndex === index ? 'bg-primary font-medium' : 'text-gray-500'"
|
||||
@click="handleOnTabChange({ index })">
|
||||
{{ tab.label }}
|
||||
</view>
|
||||
<wd-sticky :offset-top="offsetTop">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view v-for="(tab, index) in archiveTabs" :key="tab.key"
|
||||
class="uh-global-card-glass uh-shadow-xs mb-2 ml-3 inline-flex border rounded-2xl px-4 py-2 text-xs"
|
||||
:class="activeTabIndex === index ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'"
|
||||
@click="handleOnTabChange({ index })">
|
||||
{{ tab.label }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
</wd-sticky>
|
||||
|
||||
@@ -1,259 +1,248 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
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'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { checkAvatarUrl } from '@/utils/url'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { sleep } from '@/utils/common'
|
||||
import type { ICategory, IPost } from '@/api/types/halo'
|
||||
import { computed, ref } from 'vue'
|
||||
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'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import { checkAvatarUrl } from '@/utils/url'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { sleep } from '@/utils/common'
|
||||
import type { ICategory, IPost } from '@/api/types/halo'
|
||||
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '文章列表',
|
||||
navigationStyle: 'custom',
|
||||
enablePullDownRefresh: true,
|
||||
},
|
||||
})
|
||||
definePage({
|
||||
style: {
|
||||
navigationBarTitleText: '文章列表',
|
||||
navigationStyle: 'custom',
|
||||
enablePullDownRefresh: true,
|
||||
},
|
||||
})
|
||||
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const appConfigStore = useAppConfigStore()
|
||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const appConfigStore = useAppConfigStore()
|
||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||
|
||||
const settingStore = useSettingStore()
|
||||
const settingStore = useSettingStore()
|
||||
|
||||
/** 文章列表页列表布局(偏好设置驱动:single=单列 / double=双列) */
|
||||
const articlesListLayout = computed(() => settingStore.settings.articlesListLayout)
|
||||
/** 文章列表页列表布局(偏好设置驱动:single=单列 / double=双列) */
|
||||
const articlesListLayout = computed(() => settingStore.settings.articlesListLayout)
|
||||
|
||||
/* ---------------- 状态 ---------------- */
|
||||
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||
const articleList = ref<IPost[]>([])
|
||||
const queryParams = ref({ size: 10, page: 1 })
|
||||
/* ---------------- 状态 ---------------- */
|
||||
const { loadingStatus, loadMoreStatus, updateLoadingStatus, updateLoadMoreStatus, resetLoadMoreStatus } = useDataLoadingStatus()
|
||||
const articleList = ref<IPost[]>([])
|
||||
const queryParams = ref({ size: 10, page: 1 })
|
||||
|
||||
interface IFilterOption {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
interface IFilterOption {
|
||||
label : string
|
||||
value : string
|
||||
}
|
||||
|
||||
const categoryList = ref<ICategory[]>([])
|
||||
const categoryList = ref<ICategory[]>([])
|
||||
|
||||
const sortMap: Record<string, string[]> = {
|
||||
default: ['spec.pinned,desc', 'spec.publishTime,desc'],
|
||||
latest: ['spec.publishTime,desc'],
|
||||
oldest: ['spec.publishTime,asc'],
|
||||
pinned: ['spec.pinned,desc'],
|
||||
}
|
||||
const sortMap : Record<string, string[]> = {
|
||||
default: ['spec.pinned,desc', 'spec.publishTime,desc'],
|
||||
latest: ['spec.publishTime,desc'],
|
||||
oldest: ['spec.publishTime,asc'],
|
||||
pinned: ['spec.pinned,desc'],
|
||||
}
|
||||
|
||||
const categoryOptions = computed<IFilterOption[]>(() => [
|
||||
{ label: '全部', value: '' },
|
||||
...categoryList.value.map(c => ({ label: c.spec.displayName, value: c.metadata.name })),
|
||||
])
|
||||
const categoryOptions = computed<IFilterOption[]>(() => [
|
||||
{ label: '全部', value: '' },
|
||||
...categoryList.value.map(c => ({ label: c.spec.displayName, value: c.metadata.name })),
|
||||
])
|
||||
|
||||
const sortOptions: IFilterOption[] = [
|
||||
{ label: '默认排序', value: 'default' },
|
||||
{ label: '最新', value: 'latest' },
|
||||
{ label: '最旧', value: 'oldest' },
|
||||
{ label: '置顶', value: 'pinned' },
|
||||
]
|
||||
const sortOptions : IFilterOption[] = [
|
||||
{ label: '默认排序', value: 'default' },
|
||||
{ label: '最新', value: 'latest' },
|
||||
{ label: '最旧', value: 'oldest' },
|
||||
{ label: '置顶', value: 'pinned' },
|
||||
]
|
||||
|
||||
const filterValues = ref<Record<string, string>>({ category: '', sort: 'default' })
|
||||
const filterValues = ref<Record<string, string>>({ category: '', sort: 'default' })
|
||||
|
||||
/** 切换分类/排序:重置分页并重新查询 */
|
||||
function handleSelectFilter(key: 'category' | 'sort', value: string) {
|
||||
if (filterValues.value[key] === value){ return }
|
||||
filterValues.value[key] = value
|
||||
resetLoadMoreStatus()
|
||||
articleList.value = []
|
||||
queryParams.value.page = 1
|
||||
handleGetArticleList()
|
||||
}
|
||||
/** 切换分类/排序:重置分页并重新查询 */
|
||||
function handleSelectFilter(key : 'category' | 'sort', value : string) {
|
||||
if (filterValues.value[key] === value) { return }
|
||||
filterValues.value[key] = value
|
||||
resetLoadMoreStatus()
|
||||
articleList.value = []
|
||||
queryParams.value.page = 1
|
||||
handleGetArticleList()
|
||||
}
|
||||
|
||||
/** 拉取分类列表(用于筛选选项) */
|
||||
async function handleGetCategoryList() {
|
||||
try {
|
||||
const res = await getCategoryList({ page: 1, size: 0, tree: true })
|
||||
categoryList.value = res.data.items || []
|
||||
}
|
||||
catch (err) {
|
||||
console.error('获取分类列表失败', err)
|
||||
}
|
||||
}
|
||||
/** 拉取分类列表(用于筛选选项) */
|
||||
async function handleGetCategoryList() {
|
||||
try {
|
||||
const res = await getCategoryList({ page: 1, size: 0, tree: true })
|
||||
categoryList.value = res.data.items || []
|
||||
}
|
||||
catch (err) {
|
||||
console.error('获取分类列表失败', err)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- 数据加载 ---------------- */
|
||||
async function handleGetArticleList() {
|
||||
if (calcAuditModeEnabled.value) {
|
||||
// 审核模式
|
||||
resetLoadMoreStatus()
|
||||
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
||||
try {
|
||||
const res = await getPostList({ page: 1, size: 0, sort: ['spec.publishTime,desc'] })
|
||||
const filtered = res.data.items.filter(item => auditPostNames.includes(item.metadata.name))
|
||||
articleList.value = filtered.map((item) => {
|
||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||
return item
|
||||
})
|
||||
await sleep(600)
|
||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: 'noMore',
|
||||
hasNext: false,
|
||||
})
|
||||
}
|
||||
catch (err) {
|
||||
console.error('获取审核文章失败', err)
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: 'error',
|
||||
})
|
||||
}
|
||||
finally {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
return
|
||||
}
|
||||
/* ---------------- 数据加载 ---------------- */
|
||||
async function handleGetArticleList() {
|
||||
if (calcAuditModeEnabled.value) {
|
||||
// 审核模式
|
||||
resetLoadMoreStatus()
|
||||
const auditPostNames = appConfigStore.auditData.spec?.posts || []
|
||||
try {
|
||||
const res = await getPostList({ page: 1, size: 0, sort: ['spec.publishTime,desc'] })
|
||||
const filtered = res.data.items.filter(item => auditPostNames.includes(item.metadata.name))
|
||||
articleList.value = filtered.map((item) => {
|
||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||
return item
|
||||
})
|
||||
await sleep(600)
|
||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: 'noMore',
|
||||
hasNext: false,
|
||||
})
|
||||
}
|
||||
catch (err) {
|
||||
console.error('获取审核文章失败', err)
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: 'error',
|
||||
})
|
||||
}
|
||||
finally {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (!loadMoreStatus.value.active) {
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||
}
|
||||
if (!loadMoreStatus.value.active) {
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||
}
|
||||
|
||||
try {
|
||||
const category = filterValues.value.category || ''
|
||||
const params = {
|
||||
...queryParams.value,
|
||||
sort: sortMap[filterValues.value.sort] || sortMap.default,
|
||||
}
|
||||
// 注意:/posts 公开接口不支持 category 过滤参数,分类筛选需走分类下文章接口
|
||||
const res = category
|
||||
? await getCategoryPostList(category, params)
|
||||
: await getPostList(params)
|
||||
articleList.value = (loadMoreStatus.value.active
|
||||
? articleList.value.concat(res.data.items)
|
||||
: res.data.items).map((item) => {
|
||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||
return item
|
||||
})
|
||||
if (!loadMoreStatus.value.active) {
|
||||
await sleep(600)
|
||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||
}
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||
hasNext: res.data.hasNext,
|
||||
})
|
||||
}
|
||||
catch (err) {
|
||||
console.error('获取文章失败', err)
|
||||
if (loadMoreStatus.value.active) {
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: 'error',
|
||||
})
|
||||
}
|
||||
else {
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||
}
|
||||
}
|
||||
finally {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
}
|
||||
try {
|
||||
const category = filterValues.value.category || ''
|
||||
const params = {
|
||||
...queryParams.value,
|
||||
sort: sortMap[filterValues.value.sort] || sortMap.default,
|
||||
}
|
||||
// 注意:/posts 公开接口不支持 category 过滤参数,分类筛选需走分类下文章接口
|
||||
const res = category
|
||||
? await getCategoryPostList(category, params)
|
||||
: await getPostList(params)
|
||||
articleList.value = (loadMoreStatus.value.active
|
||||
? articleList.value.concat(res.data.items)
|
||||
: res.data.items).map((item) => {
|
||||
item.owner.avatar = checkAvatarUrl(item.owner.avatar)
|
||||
return item
|
||||
})
|
||||
if (!loadMoreStatus.value.active) {
|
||||
await sleep(600)
|
||||
updateLoadingStatus(articleList.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||
}
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: res.data.hasNext ? 'loadMore' : 'noMore',
|
||||
hasNext: res.data.hasNext,
|
||||
})
|
||||
}
|
||||
catch (err) {
|
||||
console.error('获取文章失败', err)
|
||||
if (loadMoreStatus.value.active) {
|
||||
updateLoadMoreStatus({
|
||||
active: false,
|
||||
status: 'error',
|
||||
})
|
||||
}
|
||||
else {
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||
}
|
||||
}
|
||||
finally {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
onPageScroll((option: Page.PageScrollOption) => {
|
||||
updatePageScrollValue(option.scrollTop)
|
||||
})
|
||||
onPageScroll((option : Page.PageScrollOption) => {
|
||||
updatePageScrollValue(option.scrollTop)
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
handleGetCategoryList()
|
||||
handleGetArticleList()
|
||||
})
|
||||
onLoad(() => {
|
||||
handleGetCategoryList()
|
||||
handleGetArticleList()
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
if (calcAuditModeEnabled.value) {
|
||||
uni.stopPullDownRefresh()
|
||||
return
|
||||
}
|
||||
resetLoadMoreStatus()
|
||||
queryParams.value.page = 1
|
||||
articleList.value = []
|
||||
handleGetArticleList()
|
||||
})
|
||||
onPullDownRefresh(() => {
|
||||
if (calcAuditModeEnabled.value) {
|
||||
uni.stopPullDownRefresh()
|
||||
return
|
||||
}
|
||||
resetLoadMoreStatus()
|
||||
queryParams.value.page = 1
|
||||
articleList.value = []
|
||||
handleGetArticleList()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
if (calcAuditModeEnabled.value) {
|
||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
||||
return
|
||||
}
|
||||
// 正在加载时阻止重复请求
|
||||
if (loadMoreStatus.value.active) {
|
||||
return
|
||||
}
|
||||
// 有更多数据时继续加载
|
||||
if (loadMoreStatus.value.hasNext) {
|
||||
queryParams.value.page += 1
|
||||
updateLoadMoreStatus({
|
||||
active: true,
|
||||
status: 'loading',
|
||||
})
|
||||
handleGetArticleList()
|
||||
}
|
||||
})
|
||||
onReachBottom(() => {
|
||||
if (calcAuditModeEnabled.value) {
|
||||
uni.showToast({ icon: 'none', title: '没有更多数据了' })
|
||||
return
|
||||
}
|
||||
// 正在加载时阻止重复请求
|
||||
if (loadMoreStatus.value.active) {
|
||||
return
|
||||
}
|
||||
// 有更多数据时继续加载
|
||||
if (loadMoreStatus.value.hasNext) {
|
||||
queryParams.value.page += 1
|
||||
updateLoadMoreStatus({
|
||||
active: true,
|
||||
status: 'loading',
|
||||
})
|
||||
handleGetArticleList()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="min-h-screen w-screen flex flex-col bg-page">
|
||||
<uh-navbar :scroll-y="scrollY" default-title="文章列表" title-color="text-gray-900" />
|
||||
<view class="min-h-screen w-screen flex flex-col bg-page">
|
||||
<uh-navbar :scroll-y="scrollY" default-title="文章列表" title-color="text-gray-900" />
|
||||
|
||||
<wd-sticky v-if="categoryOptions.length > 1" class="w-full">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap pt-2">
|
||||
<view
|
||||
v-for="cate in categoryOptions" :key="cate.value"
|
||||
class="uh-global-card-glass uh-shadow-xs mb-1 ml-3 inline-flex border rounded-2xl px-4 py-1 text-sm"
|
||||
:class="{ 'bg-primary text-gray-900 font-bold': filterValues.category === cate.value }"
|
||||
@click="handleSelectFilter('category', cate.value)"
|
||||
>
|
||||
{{ cate.label }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
</wd-sticky>
|
||||
<wd-sticky v-if="categoryOptions.length > 1" class="w-screen overflow-hidden" :offset-top="offsetTop">
|
||||
<view class="w-screen overflow-hidden">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap pb-1.5">
|
||||
<view v-for="cate in categoryOptions" :key="cate.value"
|
||||
class="uh-global-card-glass uh-shadow-xs ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||
:class="{ 'bg-primary text-gray-900 font-semibold': filterValues.category === cate.value }"
|
||||
@click="handleSelectFilter('category', cate.value)">
|
||||
{{ cate.label }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view class="box-border flex gap-2 px-3 py-1.5">
|
||||
<view v-for="opt in sortOptions" :key="opt.value"
|
||||
class="uh-global-card-glass uh-shadow-xs inline-flex border rounded-full px-3 py-1 text-xs"
|
||||
:class="{ 'bg-secondary text-gray-900': filterValues.sort === opt.value }"
|
||||
@click="handleSelectFilter('sort', opt.value)">
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</wd-sticky>
|
||||
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view class="box-border flex gap-2 px-3 py-2">
|
||||
<view
|
||||
v-for="opt in sortOptions" :key="opt.value"
|
||||
class="uh-global-card-glass uh-shadow-xs inline-flex border rounded-full px-3 py-1 text-xs"
|
||||
:class="{ 'bg-secondary text-gray-900 font-bold': filterValues.sort === opt.value }"
|
||||
@click="handleSelectFilter('sort', opt.value)"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :loading-status="loadingStatus"
|
||||
empty-text="啊偶,还没有任何内容哦~" min-height="75vh" @refresh="handleGetArticleList" />
|
||||
|
||||
<uh-data-loading
|
||||
v-if="loadingStatus !== DataLoadingStatusEnum.Success"
|
||||
:loading-status="loadingStatus"
|
||||
empty-text="啊偶,还没有任何内容哦~"
|
||||
min-height="75vh"
|
||||
@refresh="handleGetArticleList"
|
||||
/>
|
||||
|
||||
<view v-else class="box-border flex flex-col gap-4 p-3">
|
||||
<view :class="articlesListLayout === 'double' ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-3'">
|
||||
<uh-article-card
|
||||
v-for="(article, index) in articleList"
|
||||
:key="article.metadata.name || index"
|
||||
from="articles"
|
||||
:variant="articlesListLayout === 'double' ? 'grid' : 'list'"
|
||||
:article="article"
|
||||
:audit-mode="calcAuditModeEnabled"
|
||||
/>
|
||||
</view>
|
||||
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="box-border flex flex-col gap-4 p-3">
|
||||
<view :class="articlesListLayout === 'double' ? 'grid grid-cols-2 gap-3' : 'flex flex-col gap-3'">
|
||||
<uh-article-card v-for="(article, index) in articleList" :key="article.metadata.name || index"
|
||||
from="articles" :variant="articlesListLayout === 'double' ? 'grid' : 'list'" :article="article"
|
||||
:audit-mode="calcAuditModeEnabled" />
|
||||
</view>
|
||||
<uh-data-loadmore :status="loadMoreStatus.status" :text="loadMoreStatus.text" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -5,6 +5,7 @@ import { formatTime } from '@/utils/formatTime'
|
||||
import { useFavoritesStore } from '@/store/favorites'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import type { FavoriteKind, IFavoriteItem } from '@/utils/favorite'
|
||||
|
||||
definePage({
|
||||
@@ -14,6 +15,7 @@ definePage({
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const favoritesStore = useFavoritesStore()
|
||||
|
||||
@@ -81,18 +83,16 @@ onPageScroll((option: Page.PageScrollOption) => {
|
||||
<uh-navbar :scroll-y="scrollY" default-title="我的收藏" title-color="text-gray-900"></uh-navbar>
|
||||
|
||||
<!-- 顶部类型 Tab(与图库页同款:吸顶玻璃胶囊 chip) -->
|
||||
<wd-sticky>
|
||||
<scroll-view scroll-x class="w-full whitespace-nowrap">
|
||||
<view class="flex gap-2 px-3 pb-1 pt-3">
|
||||
<view
|
||||
v-for="tab in tabList" :key="tab.key"
|
||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
||||
:class="tab.key === activeKind ? 'bg-primary font-bold' : 'text-gray-500'"
|
||||
@click="handleSwitchTab(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<text v-if="tab.count > 0">({{ tab.count }})</text>
|
||||
</view>
|
||||
<wd-sticky :offset-top="offsetTop">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view
|
||||
v-for="tab in tabList" :key="tab.key"
|
||||
class="uh-global-card-glass uh-shadow-xs mb-2 ml-3 inline-flex border rounded-2xl px-4 py-2 text-xs"
|
||||
:class="tab.key === activeKind ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'"
|
||||
@click="handleSwitchTab(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<text v-if="tab.count > 0">({{ tab.count }})</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</wd-sticky>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useSettingStore } from '@/store/setting'
|
||||
import { sleep } from '@/utils/common'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||
import type { ILink, ILinkGroup } from '@/api/types/halo'
|
||||
@@ -21,6 +22,7 @@ definePage({
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const appConfigStore = useAppConfigStore()
|
||||
const settingStore = useSettingStore()
|
||||
@@ -416,17 +418,15 @@ onReachBottom(() => {
|
||||
<uh-navbar :scroll-y="scrollY" default-title="友情链接" title-color="text-gray-900" />
|
||||
|
||||
<!-- 顶部 -->
|
||||
<wd-sticky>
|
||||
<scroll-view scroll-x class="w-full whitespace-nowrap">
|
||||
<view class="flex gap-2 px-3 pb-1 pt-3">
|
||||
<view
|
||||
v-for="(tab, index) in friendLinkTabs" :key="tab.key"
|
||||
class="uh-global-card-glass uh-shadow-xs inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
||||
:class="activeTabIndex === index ? 'bg-primary font-bold' : 'text-gray-500'"
|
||||
@click="handleOnTabChange({ index })"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</view>
|
||||
<wd-sticky :offset-top="offsetTop">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view
|
||||
v-for="(tab, index) in friendLinkTabs" :key="tab.key"
|
||||
class="uh-global-card-glass uh-shadow-xs mb-2 ml-3 inline-flex border rounded-2xl px-4 py-2 text-xs"
|
||||
:class="activeTabIndex === index ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'"
|
||||
@click="handleOnTabChange({ index })"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
</wd-sticky>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { sleep } from '@/utils/common'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import type { ILoveDailyItem } from '@/api/types/uni-halo'
|
||||
|
||||
definePage({
|
||||
@@ -19,6 +20,7 @@
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
|
||||
/* ---------------- 展示层类型 ---------------- */
|
||||
@@ -331,7 +333,7 @@
|
||||
<view class="uh-global-love-page box-border min-h-screen w-screen flex flex-col">
|
||||
<uh-navbar :scroll-y="scrollY" default-title="恋爱清单" title-color="text-love" back-class="text-love"/>
|
||||
|
||||
<wd-sticky>
|
||||
<wd-sticky :offset-top="offsetTop">
|
||||
<view class="box-border px-3 pb-1 pt-2">
|
||||
<view class="box-border flex items-center justify-between gap-x-2">
|
||||
<view v-for="f in filterConfig" :key="f.key"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { getNotices } from '@/api/uni-halo'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import { checkImageUrl } from '@/utils/url'
|
||||
import { sleep } from '@/utils/common'
|
||||
import type { INoticeListVo } from '@/api/types/uni-halo'
|
||||
@@ -16,6 +17,7 @@
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const PAGE_SIZE = 100
|
||||
|
||||
@@ -188,21 +190,19 @@
|
||||
<!-- 自定义导航 -->
|
||||
<uh-navbar :scroll-y="scrollY" default-title="公告中心" title-color="text-gray-900" />
|
||||
|
||||
<wd-sticky>
|
||||
<scroll-view scroll-x class="w-full whitespace-nowrap" :show-scrollbar="false">
|
||||
<view class="box-border flex gap-2 px-3 pb-1 pt-2">
|
||||
<view class="flex-1 uh-global-card-glass uh-shadow-xs inline-flex border rounded-2xl px-4 py-1.5 text-sm"
|
||||
:class="activeType === '' ? 'bg-primary font-bold' : 'text-gray-500'" @click="activeType = ''">
|
||||
全部
|
||||
</view>
|
||||
<view v-for="(type) in typeOptions" :key="type.typeDisplayName"
|
||||
class="flex-1 box-border uh-global-card-glass uh-shadow-xs inline-flex items-center gap-1 border rounded-2xl px-4 py-1.5 text-sm"
|
||||
:class="activeType === type.typeName ? 'bg-primary font-bold' : 'text-gray-500'"
|
||||
@click="activeType = activeType === type.typeName ? '' : type.typeName">
|
||||
<view v-if="type.typeColor" class="shrink-0 h-2 w-2 rounded-full"
|
||||
:style="{ backgroundColor: type.typeColor }" />
|
||||
<view class="shrink-0">{{ type.typeDisplayName }}</view>
|
||||
</view>
|
||||
<wd-sticky :offset-top="offsetTop">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view class="uh-global-card-glass uh-shadow-xs mb-2 ml-3 inline-flex border rounded-2xl px-4 py-2 text-xs"
|
||||
:class="activeType === '' ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'" @click="activeType = ''">
|
||||
全部
|
||||
</view>
|
||||
<view v-for="(type) in typeOptions" :key="type.typeDisplayName"
|
||||
class="mb-2 ml-3 box-border uh-global-card-glass uh-shadow-xs inline-flex items-center gap-1 border rounded-2xl px-4 py-2 text-xs"
|
||||
:class="activeType === type.typeName ? 'bg-primary text-gray-900 font-semibold' : 'text-gray-500'"
|
||||
@click="activeType = activeType === type.typeName ? '' : type.typeName">
|
||||
<view v-if="type.typeColor" class="shrink-0 h-2 w-2 rounded-full"
|
||||
:style="{ backgroundColor: type.typeColor }" />
|
||||
<view class="shrink-0">{{ type.typeDisplayName }}</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</wd-sticky>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { useAppConfigStore } from '@/store/appConfig'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import { usePageScroll } from '@/hooks/usePageScroll'
|
||||
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
|
||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||
import { markdownConfig } from '@/config/markdown'
|
||||
import { debounce } from '@/utils/debounce'
|
||||
@@ -18,6 +19,7 @@
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const appConfigStore = useAppConfigStore()
|
||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||
@@ -219,7 +221,7 @@
|
||||
|
||||
<template v-else>
|
||||
<!-- 顶部搜索框-->
|
||||
<wd-sticky>
|
||||
<wd-sticky :offset-top="offsetTop">
|
||||
<view class="w-screen box-border px-3 py-2">
|
||||
<view class="box-border uh-global-card-glass h-9 flex items-center gap-3 rounded-full pl-1 pr-3">
|
||||
<wd-icon name="search" size="16px" />
|
||||
|
||||
@@ -225,7 +225,7 @@
|
||||
<wd-sticky v-if="category.list.length!==0" class="w-full" :offset-top="offsetTop">
|
||||
<scroll-view :scroll-x="true" :show-scrollbar="false" class="w-full whitespace-nowrap">
|
||||
<view v-for="(cate, index) in category.list" :key="cate.spec.displayName"
|
||||
class="uh-global-card-glass uh-shadow-xs mb-2 ml-3 inline-flex border rounded-2xl px-4 py-2 text-xs"
|
||||
class="uh-global-card-glass shadow-none mb-2 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-xs"
|
||||
:class="{ 'bg-primary text-gray-900 font-semibold': index === category.activeIndex }"
|
||||
@click="handleGetDataByCategory(index, cate)">
|
||||
{{ cate.spec.displayName }}
|
||||
|
||||
Reference in New Issue
Block a user