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,16 +261,14 @@
|
||||
<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">
|
||||
<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 inline-block border rounded-2xl px-5 py-2 text-2xs"
|
||||
:class="activeTabIndex === index ? 'bg-primary font-medium' : 'text-gray-500'"
|
||||
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>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</wd-sticky>
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ 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'
|
||||
@@ -18,6 +19,7 @@ definePage({
|
||||
},
|
||||
})
|
||||
|
||||
const { height: offsetTop } = useCustomNavbarPlaceholder()
|
||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||
const appConfigStore = useAppConfigStore()
|
||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||
@@ -208,50 +210,37 @@ onReachBottom(() => {
|
||||
<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)"
|
||||
>
|
||||
<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>
|
||||
</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"
|
||||
<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 font-bold': filterValues.sort === opt.value }"
|
||||
@click="handleSelectFilter('sort', opt.value)"
|
||||
>
|
||||
:class="{ 'bg-secondary text-gray-900': filterValues.sort === opt.value }"
|
||||
@click="handleSelectFilter('sort', opt.value)">
|
||||
{{ opt.label }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</wd-sticky>
|
||||
|
||||
<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"
|
||||
/>
|
||||
<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>
|
||||
|
||||
@@ -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,19 +83,17 @@ 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">
|
||||
<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 inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
||||
:class="tab.key === activeKind ? 'bg-primary font-bold' : 'text-gray-500'"
|
||||
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>
|
||||
</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,18 +418,16 @@ 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">
|
||||
<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 inline-block border rounded-2xl px-5 py-1.5 text-sm"
|
||||
:class="activeTabIndex === index ? 'bg-primary font-bold' : 'text-gray-500'"
|
||||
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>
|
||||
</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,22 +190,20 @@
|
||||
<!-- 自定义导航 -->
|
||||
<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 = ''">
|
||||
<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="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'"
|
||||
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>
|
||||
</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