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