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

refactor: 整理项目代码风格与修复细节问题

本次提交包含多项优化:
1. 修复htmlToPlainText入参类型校验逻辑
2. 移除冗余的overflow-hidden类名,调整分类组件样式
3. 新增自定义导航占位hook统一处理导航栏间距
4. 优化投票筛选选项文字大小,修复文章摘要获取逻辑
5. 重构画廊页面分类吸顶逻辑,调整分类项样式与滚动行为
6. 统一about与contact页面的模糊样式类名,调整页面内文字大小与间距
7. 重构useDataLoading工具函数的导入与代码格式
8. 优化设置页面的UI样式与按钮文字大小
9. 统一投票卡片组件的代码缩进与文字样式
10. 重构联系页面的代码格式,统一变量声明风格
This commit is contained in:
小莫唐尼
2026-09-13 03:58:05 +08:00
parent bf077a3092
commit abae523a30
11 changed files with 345 additions and 328 deletions
@@ -75,7 +75,7 @@
</script> </script>
<template> <template>
<view v-if="isEnableCategoryModule" class="overflow-hidden box-border mb-6 px-3"> <view v-if="isEnableCategoryModule" class="box-border mb-6 px-3">
<uh-section-title> <uh-section-title>
精选分类 精选分类
<template #right> <template #right>
+11 -15
View File
@@ -50,20 +50,16 @@ function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
<!-- 头部:类型/状态/已投票 --> <!-- 头部:类型/状态/已投票 -->
<view class="flex items-center justify-between"> <view class="flex items-center justify-between">
<view class="flex flex-wrap items-center gap-1"> <view class="flex flex-wrap items-center gap-1">
<text <text v-if="vote.spec?._uh_type"
v-if="vote.spec?._uh_type" class="rounded-md bg-secondary px-1.5 py-0.5 text-xs text-[#4d7c0f]">
class="rounded-md bg-secondary px-1.5 py-0.5 text-[22rpx] text-[#4d7c0f]"
>
{{ vote.spec._uh_type }} {{ vote.spec._uh_type }}
</text> </text>
<text <text v-if="vote.spec?._uh_state" class="rounded-md px-1.5 py-0.5 text-xs"
v-if="vote.spec?._uh_state" :class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]">
class="rounded-md px-1.5 py-0.5 text-[22rpx]"
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]"
>
{{ vote.spec._uh_state.state }} {{ vote.spec._uh_state.state }}
</text> </text>
<text v-if="vote.spec?.isVoted" class="rounded-md bg-primary/15 px-1.5 py-0.5 text-[22rpx] text-primary"> <text v-if="vote.spec?.isVoted"
class="rounded-md bg-primary/15 px-1.5 py-0.5 text-xs text-primary">
已投票 已投票
</text> </text>
</view> </view>
@@ -71,7 +67,7 @@ function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
</view> </view>
<!-- 标题 + 备注 --> <!-- 标题 + 备注 -->
<view class="vote-title mt-2 text-[30rpx] font-bold text-gray-900"> <view class="vote-title mt-2 text-sm font-bold text-gray-900">
{{ vote.spec?.title }} {{ vote.spec?.title }}
</view> </view>
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400"> <view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
@@ -80,16 +76,16 @@ function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
<!-- 底部:时间 + 参与人数 --> <!-- 底部:时间 + 参与人数 -->
<view class="vote-card-foot mt-3 flex items-center justify-between border-t border-black/5 pt-2"> <view class="vote-card-foot mt-3 flex items-center justify-between border-t border-black/5 pt-2">
<text v-if="vote.spec?.timeLimit === 'permanent'" class="text-[22rpx] text-gray-400"> <text v-if="vote.spec?.timeLimit === 'permanent'" class="text-xs text-gray-400">
结束:永久有效 结束:永久有效
</text> </text>
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-[22rpx] text-gray-400"> <text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-xs text-gray-400">
开始:{{ formatTime(vote.spec?.startDate) }} 开始:{{ formatTime(vote.spec?.startDate) }}
</text> </text>
<text v-else class="text-[22rpx] text-gray-400"> <text v-else class="text-xs text-gray-400">
结束:{{ formatTime(vote.spec?.endDate) }} 结束:{{ formatTime(vote.spec?.endDate) }}
</text> </text>
<text class="text-[22rpx] text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text> <text class="text-xs text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
</view> </view>
</view> </view>
</template> </template>
+24
View File
@@ -0,0 +1,24 @@
import { ref } from 'vue';
/**
* 自定义导航顶部位置
*/
export function useCustomNavbarPlaceholder(customNavbarHeight?: number) {
const height = ref(0);
function init() {
const winInfo = uni.getWindowInfo();
const safeAreaTop = winInfo.safeArea.top;
height.value += safeAreaTop + 10;
// #ifndef H5
height.value += customNavbarHeight ?? 46;
// #endif
console.log('最终高度', height.value);
}
onMounted(init);
return { height };
}
+29 -38
View File
@@ -1,22 +1,20 @@
import type { Ref } from 'vue' import { ref } from 'vue';
import { ref } from 'vue' import type { Ref } from 'vue';
import type { DataLoadingStatus } from './useDataLoadingStatus';
/** 数据加载四态(取值与 DataLoadingStatusEnum 一致,二者可互相兼容) */
export type DataLoadingStatus = 'loading' | 'error' | 'empty' | 'success' | 'noNetwork'
export interface IUseDataLoadingOptions<T> { export interface IUseDataLoadingOptions<T> {
/** 自定义判空;默认:数组看长度、对象看键数、空值视为空 */ /** 自定义判空;默认:数组看长度、对象看键数、空值视为空 */
isEmpty?: (data: T) => boolean isEmpty?: (data: T) => boolean;
/** 成功回调(数据就绪) */ /** 成功回调(数据就绪) */
onSuccess?: (data: T) => void onSuccess?: (data: T) => void;
/** 失败回调(run 已捕获异常,不会向外抛出) */ /** 失败回调(run 已捕获异常,不会向外抛出) */
onError?: (err: unknown) => void onError?: (err: unknown) => void;
} }
export interface IUseDataLoadingReturn<T, P extends unknown[]> { export interface IUseDataLoadingReturn<T, P extends unknown[]> {
data: Ref<T | undefined> data: Ref<T | undefined>;
status: Ref<DataLoadingStatus> status: Ref<DataLoadingStatus>;
run: (...args: P) => Promise<T | undefined> run: (...args: P) => Promise<T | undefined>;
} }
/** /**
@@ -29,41 +27,34 @@ export interface IUseDataLoadingReturn<T, P extends unknown[]> {
* onLoad(() => run()) * onLoad(() => run())
* onPullDownRefresh(async () => { await run(); uni.stopPullDownRefresh() }) * onPullDownRefresh(async () => { await run(); uni.stopPullDownRefresh() })
*/ */
export function useDataLoading<T, P extends unknown[] = []>( export function useDataLoading<T, P extends unknown[] = []>(fetcher: (...args: P) => Promise<T>, options: IUseDataLoadingOptions<T> = {}): IUseDataLoadingReturn<T, P> {
fetcher: (...args: P) => Promise<T>, const { isEmpty, onSuccess, onError } = options;
options: IUseDataLoadingOptions<T> = {},
): IUseDataLoadingReturn<T, P> {
const { isEmpty, onSuccess, onError } = options
const data = ref<T | undefined>(undefined) as Ref<T | undefined> const data = ref<T | undefined>(undefined) as Ref<T | undefined>;
const status = ref<DataLoadingStatus>('loading') const status = ref<DataLoadingStatus>('loading');
function calcEmpty(value: T): boolean { function calcEmpty(value: T): boolean {
if (isEmpty) if (isEmpty) return isEmpty(value);
return isEmpty(value) if (Array.isArray(value)) return value.length === 0;
if (Array.isArray(value)) if (value !== null && typeof value === 'object') return Object.keys(value).length === 0;
return value.length === 0 return value === undefined || value === null || value === '';
if (value !== null && typeof value === 'object')
return Object.keys(value).length === 0
return value === undefined || value === null || value === ''
} }
async function run(...args: P): Promise<T | undefined> { async function run(...args: P): Promise<T | undefined> {
status.value = 'loading' status.value = 'loading';
try { try {
const res = await fetcher(...args) const res = await fetcher(...args);
data.value = res data.value = res;
status.value = calcEmpty(res) ? 'empty' : 'success' status.value = calcEmpty(res) ? 'empty' : 'success';
onSuccess?.(res) onSuccess?.(res);
return res return res;
} } catch (err) {
catch (err) { console.error('[useDataLoading] 请求失败', err);
console.error('[useDataLoading] 请求失败', err) status.value = 'error';
status.value = 'error' onError?.(err);
onError?.(err) return undefined;
return undefined
} }
} }
return { data, status, run } return { data, status, run };
} }
+11 -4
View File
@@ -53,8 +53,8 @@ const appConfigStore = useAppConfigStore()
<!-- 自定义导航 --> <!-- 自定义导航 -->
<uh-navbar :scroll-y="scrollY" default-title="关于项目" title-color="text-gray-900" /> <uh-navbar :scroll-y="scrollY" default-title="关于项目" title-color="text-gray-900" />
<view class="fixed -right-8 top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] blur-xl" /> <view class="fixed -right-8 top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] uh-blur-xl" />
<view class="fixed -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl" /> <view class="fixed -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] uh-blur-xl" />
<view class="relative"> <view class="relative">
<view class="uh-global-card-glass relative flex flex-col items-center rounded-2xl px-6 pb-7 pt-10"> <view class="uh-global-card-glass relative flex flex-col items-center rounded-2xl px-6 pb-7 pt-10">
@@ -79,12 +79,12 @@ const appConfigStore = useAppConfigStore()
<view v-for="(link) in links" :key="link.title" class="flex items-center gap-3 px-4" <view v-for="(link) in links" :key="link.title" class="flex items-center gap-3 px-4"
@click="copyText(link.copy, link.tip)"> @click="copyText(link.copy, link.tip)">
<view <view
class="uh-global-card-glass uh-shadow-xs border h-10 w-10 flex shrink-0 items-center justify-center rounded-xl" class="uh-global-card-glass uh-shadow-xs border h-9 w-9 flex shrink-0 items-center justify-center rounded-xl"
:style="{ backgroundColor: `${link.tileColor}1A` }"> :style="{ backgroundColor: `${link.tileColor}1A` }">
<text class="text-sm font-bold" :style="{ color: link.tileColor }">{{ link.tileLetter }}</text> <text class="text-sm font-bold" :style="{ color: link.tileColor }">{{ link.tileLetter }}</text>
</view> </view>
<view class="min-w-0 flex flex-1 flex-col"> <view class="min-w-0 flex flex-1 flex-col">
<text class="text-sm text-gray-900 font-bold">{{ link.title }}</text> <text class="text-2xs text-gray-900 font-bold">{{ link.title }}</text>
<view class="truncate text-xs text-gray-400"> <view class="truncate text-xs text-gray-400">
{{ link.value }} {{ link.value }}
</view> </view>
@@ -96,3 +96,10 @@ const appConfigStore = useAppConfigStore()
<uh-page-copyright /> <uh-page-copyright />
</view> </view>
</template> </template>
<style scoped lang="scss">
.uh-blur-xl {
filter: blur(20rpx);
}
</style>
+15 -20
View File
@@ -91,12 +91,11 @@ onPageScroll((option: Page.PageScrollOption) => {
<!-- 自定义导航 --> <!-- 自定义导航 -->
<uh-navbar :scroll-y="scrollY" default-title="联系博主" title-color="text-gray-900" /> <uh-navbar :scroll-y="scrollY" default-title="联系博主" title-color="text-gray-900" />
<view class="fixed top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] blur-xl -right-8" /> <view class="fixed top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] uh-blur-xl -right-8" />
<view class="fixed top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl -left-10" /> <view class="fixed top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] uh-blur-xl -left-10" />
<view <view
class="uh-global-card-glass uh-shadow-xs relative box-border flex items-center justify-between rounded-xl p-4" class="uh-global-card-glass uh-shadow-xs relative box-border flex items-center justify-between rounded-xl p-4">
>
<view class="relative flex flex-1 flex-col rounded-2xl"> <view class="relative flex flex-1 flex-col rounded-2xl">
<view class="flex items-center gap-x-2 text-xs text-primary"> <view class="flex items-center gap-x-2 text-xs text-primary">
TO <text class="text-sm">·</text> 收 TO <text class="text-sm">·</text> 收
@@ -112,31 +111,26 @@ onPageScroll((option: Page.PageScrollOption) => {
</view> </view>
</view> </view>
<view <view
class="uh-global-card-glass uh-shadow-xs uh-rotate-3 relative box-border w-22 flex shrink-0 flex-col items-center justify-center gap-y-1 overflow-hidden border p-2" class="uh-global-card-glass uh-shadow-xs uh-rotate-3 relative box-border w-22 flex shrink-0 flex-col items-center justify-center gap-y-1 overflow-hidden border p-2">
>
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" /> <image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text> <text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
</view> </view>
</view> </view>
<view class="uh-global-card-glass uh-shadow-xs mt-4 box-border flex flex-col gap-y-6 rounded-xl px-4 py-3"> <view class="uh-global-card-glass uh-shadow-xs mt-4 box-border flex flex-col gap-y-6 rounded-xl px-4 py-3">
<uh-data-loading <uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh" empty-text="暂无联系方式" empty-sub-text="" />
empty-text="暂无联系方式" empty-sub-text=""
/>
<template v-else> <template v-else>
<view class="w-full flex flex-col gap-y-3"> <view class="w-full flex flex-col gap-y-3">
<view class="text-md text-gray-900"> <view class="text-md text-gray-900">
展信安: 展信安:
</view> </view>
<view v-if="bloggerInfo.intro" class="text-sm text-gray-900"> <view v-if="bloggerInfo.intro" class="text-sm text-gray-900">
<mp-html <mp-html lazy-load :domain="markdownConfig.domain ?? ''"
lazy-load :domain="markdownConfig.domain ?? ''"
:loading-img="markdownConfig.loadingGif" scroll-table selectable :loading-img="markdownConfig.loadingGif" scroll-table selectable
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle" :tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true" :content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
:show-language-name="true" copy-by-long-press :show-language-name="true" copy-by-long-press />
/>
</view> </view>
<view v-else class="py-4 text-sm text-gray-600"> <view v-else class="py-4 text-sm text-gray-600">
祝你早安,午安,晚安。每天都有好心情,生活愉快! 祝你早安,午安,晚安。每天都有好心情,生活愉快!
@@ -151,14 +145,11 @@ onPageScroll((option: Page.PageScrollOption) => {
<view class="text-md mb-2 text-gray-900"> <view class="text-md mb-2 text-gray-900">
若有意,可依此觅: 若有意,可依此觅:
</view> </view>
<view <view v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
v-for="item in socialList" :key="item.name" class="flex items-center gap-3" @click="handleOnClick(item)">
@click="handleOnClick(item)"
>
<view <view
class="uh-global-card-glass uh-shadow-xs h-11 w-11 flex shrink-0 items-center justify-center border rounded-xl" class="uh-global-card-glass uh-shadow-xs h-11 w-11 flex shrink-0 items-center justify-center border rounded-xl"
:style="{ backgroundColor: item.bgColor, color: item.color }" :style="{ backgroundColor: item.bgColor, color: item.color }">
>
<text class="text-sm font-bold" :style="{ color: item.color }"> <text class="text-sm font-bold" :style="{ color: item.color }">
{{ item.name ? item.name.charAt(0) : '' }} {{ item.name ? item.name.charAt(0) : '' }}
</text> </text>
@@ -181,4 +172,8 @@ onPageScroll((option: Page.PageScrollOption) => {
.uh-rotate-3 { .uh-rotate-3 {
transform: rotate(3deg); transform: rotate(3deg);
} }
.uh-blur-xl {
filter: blur(20rpx);
}
</style> </style>
+18 -17
View File
@@ -127,9 +127,9 @@
<!-- 内容区域 --> <!-- 内容区域 -->
<view class="box-border flex flex-col gap-y-6 p-3"> <view class="box-border flex flex-col gap-y-6 p-3">
<!-- 顶部分段器:布局 / 功能 --> <!-- 顶部分段器:布局 / 功能 -->
<view class="uh-global-card-glass flex rounded-full p-1"> <view class="uh-global-card-glass uh-shadow-xs flex rounded-xl p-1">
<view v-for="tab in SETTING_TABS" :key="tab.key" class="flex-1 rounded-full py-1.5 text-center text-sm" <view v-for="tab in SETTING_TABS" :key="tab.key" class="flex-1 rounded-lg py-2 text-center text-2xs"
:class="activeTab === tab.key ? 'bg-primary font-bold' : 'text-gray-500'" :class="activeTab === tab.key ? 'bg-primary font-medium' : 'text-gray-500'"
@click="activeTab = tab.key"> @click="activeTab = tab.key">
{{ tab.label }} {{ tab.label }}
</view> </view>
@@ -139,24 +139,24 @@
<template v-if="activeTab === 'layout'"> <template v-if="activeTab === 'layout'">
<view v-for="group in layoutGroups" :key="group.key" class="flex flex-col gap-y-3"> <view v-for="group in layoutGroups" :key="group.key" class="flex flex-col gap-y-3">
<uh-section-title>{{ group.label }}</uh-section-title> <uh-section-title>{{ group.label }}</uh-section-title>
<view class="uh-global-card-glass overflow-hidden rounded-2xl"> <view class="uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl">
<view v-for="(row, index) in group.rows" :key="row.key" <view v-for="(row, index) in group.rows" :key="row.key"
class="pick-row flex items-center justify-between px-4 py-4" class="pick-row flex items-center justify-between px-4 py-4"
:class="index < group.rows.length - 1 ? 'border-b border-black/5' : ''" :class="index < group.rows.length - 1 ? 'border-b border-black/5' : ''"
@click="handleOpenEnum(row)"> @click="handleOpenEnum(row)">
<view class="row-left flex flex-col gap-1"> <view class="row-left flex flex-col gap-1">
<text class="row-label text-[28rpx] text-gray-900 font-bold">{{ row.label }}</text> <text class="row-label text-sm text-gray-900 font-bold">{{ row.label }}</text>
<view class="flex items-center gap-2"> <view class="flex items-center gap-2">
<text v-if="row.following" class="row-sub text-2xs text-gray-400">跟随站点默认</text> <text v-if="row.following" class="row-sub text-xs text-gray-400">跟随站点默认</text>
<view v-else <view v-else
class="rounded-full bg-secondary px-2 py-0.5 text-[20rpx] text-[#4d7c0f] leading-none"> class="rounded-full bg-secondary px-2 py-0.5 text-xs text-[#4d7c0f] leading-none">
已自定义 已自定义
</view> </view>
</view> </view>
</view> </view>
<view class="row-value flex items-center gap-2"> <view class="flex items-center gap-2 text-gray-400">
<text class="value-text text-[26rpx] text-gray-400">{{ row.displayValue }}</text> <text class="text-xs">{{ row.displayValue }}</text>
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" /> <wd-icon name="arrow-right" size="24rpx" />
</view> </view>
</view> </view>
</view> </view>
@@ -172,15 +172,15 @@
<text class="text-2xs text-gray-400">一些常用的功能性设置</text> <text class="text-2xs text-gray-400">一些常用的功能性设置</text>
</template> </template>
</uh-section-title> </uh-section-title>
<view class="setting-sheet uh-global-card-glass overflow-hidden rounded-2xl"> <view class="setting-sheet uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl">
<template v-for="(row, index) in featureRows" :key="row.key"> <template v-for="(row, index) in featureRows" :key="row.key">
<!-- 布尔项:内联分段器(默认 / 开 / 关) --> <!-- 布尔项:内联分段器(默认 / 开 / 关) -->
<view v-if="row.kind === 'bool'" class="box-border p-3" <view v-if="row.kind === 'bool'" class="box-border p-3"
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''"> :class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
<view class="flex items-center justify-between"> <view class="flex items-center justify-between">
<text class="row-label text-[28rpx] text-gray-900 font-bold">{{ row.label }}</text> <text class="row-label text-sm text-gray-900 font-bold">{{ row.label }}</text>
<view class="flex items-center gap-2"> <view class="flex items-center gap-2">
<text v-if="row.following" class="row-sub text-2xs text-gray-400">默认</text> <text v-if="row.following" class="row-sub text-xs text-gray-400">默认</text>
<view v-else <view v-else
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none"> class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
已自定义 已自定义
@@ -225,9 +225,9 @@
</template> </template>
</view> </view>
</view> </view>
<view class="row-value flex items-center gap-2"> <view class="flex items-center gap-2 text-gray-400">
<text class="value-text text-[26rpx] text-gray-400">{{ row.displayValue }}</text> <text class="text-xs">{{ row.displayValue }}</text>
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" /> <wd-icon name="arrow-right" size="24rpx" />
</view> </view>
</view> </view>
</template> </template>
@@ -236,7 +236,7 @@
</template> </template>
<!-- 底部操作栏--> <!-- 底部操作栏-->
<view class="box-border w-full"> <view class="box-border w-full">
<uh-button custom-class="uh-global-card-glass py-2 !rounded-xl" @click="handleResetAll"> <uh-button custom-class="uh-global-card-glass py-2.5 text-xs !rounded-xl" @click="handleResetAll">
恢复默认 恢复默认
</uh-button> </uh-button>
</view> </view>
@@ -275,6 +275,7 @@
.wd-picker-view__mask { .wd-picker-view__mask {
background: transparent !important; background: transparent !important;
} }
.wd-picker-view__roller { .wd-picker-view__roller {
border-radius: 16rpx !important; border-radius: 16rpx !important;
} }
+1 -1
View File
@@ -357,7 +357,7 @@
</view> </view>
<view class="flex flex-col gap-2"> <view class="flex flex-col gap-2">
<view v-for="opt in filterPopup.item.options" :key="opt.label" <view v-for="opt in filterPopup.item.options" :key="opt.label"
class="uh-global-card-glass shadow-none border box-border rounded-xl px-5 py-2 text-center text-sm" class="uh-global-card-glass shadow-none border box-border rounded-xl px-5 py-2 text-center text-xs"
:class="filterValues[filterPopup.item.key] === opt.value ? 'bg-primary text-gray-900 font-bold' : 'text-gray-700'" :class="filterValues[filterPopup.item.key] === opt.value ? 'bg-primary text-gray-900 font-bold' : 'text-gray-700'"
@click="handleSelectFilter(opt)"> @click="handleSelectFilter(opt)">
{{ opt.label }} {{ opt.label }}
+6 -5
View File
@@ -8,8 +8,8 @@
import { usePageScroll } from '@/hooks/usePageScroll' import { usePageScroll } from '@/hooks/usePageScroll'
import { sleep } from '@/utils/common' import { sleep } from '@/utils/common'
import { t } from '@/locale' import { t } from '@/locale'
import { isWechat } from '@/utils/platform'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus' import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
import type { IPhoto, IPhotoGroup } from '@/api/types/halo' import type { IPhoto, IPhotoGroup } from '@/api/types/halo'
definePage({ definePage({
@@ -20,6 +20,7 @@
}, },
}) })
const { height: offsetTop } = useCustomNavbarPlaceholder()
const { scrollY, updatePageScrollValue } = usePageScroll() const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore() const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs) const haloConfigs = computed(() => appConfigStore.configs)
@@ -221,11 +222,11 @@
:checking="checking" @on-refresh="checkPluginAvailable" /> :checking="checking" @on-refresh="checkPluginAvailable" />
<template v-else> <template v-else>
<wd-sticky v-if="category.list.length!==0" class="w-full" :offset-top="isWechat?56:0"> <wd-sticky v-if="category.list.length!==0" class="w-full" :offset-top="offsetTop">
<scroll-view :scroll-x="true" class="w-full whitespace-nowrap pt-2"> <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-1 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-2xs" class="uh-global-card-glass uh-shadow-xs mb-2 ml-3 inline-flex border rounded-2xl px-4 py-2 text-xs"
:class="{ 'bg-primary text-gray-900 font-bold': 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 }}
<text v-if="cate.spec.displayName!=='全部'"> <text v-if="cate.spec.displayName!=='全部'">
+4 -2
View File
@@ -38,9 +38,11 @@ const POST_EXCERPT_MAX = 120
/** 瞬间正文截断字数 */ /** 瞬间正文截断字数 */
const MOMENT_EXCERPT_MAX = 200 const MOMENT_EXCERPT_MAX = 200
/** 取文章摘要文本(excerpt 优先,兜底从正文抽取) */ /** 取文章摘要文本(excerpt 优先,兜底从正文抽取;候选字段可能被接口返回非字符串,逐个过滤) */
function getPostExcerptText(post: IPost): string { function getPostExcerptText(post: IPost): string {
return extractPlainExcerpt(post.spec.excerpt || post.content?.content || post.content?.raw, POST_EXCERPT_MAX) const candidates = [post.spec.excerpt, post.content?.content, post.content?.raw]
const source = candidates.find((item): item is string => typeof item === 'string' && item.trim() !== '')
return extractPlainExcerpt(source, POST_EXCERPT_MAX)
} }
/** 文章 → 收藏快照 */ /** 文章 → 收藏快照 */
+1 -1
View File
@@ -21,7 +21,7 @@ const MD_PREFIX_REG = /^\s{0,3}(#{1,6}[ \t]|>|[+*-][ \t]|\d+[.、)][ \t]|```|~~~
* @param source 原文(可为空) * @param source 原文(可为空)
*/ */
export function htmlToPlainText(source?: string): string { export function htmlToPlainText(source?: string): string {
if (!source) if (typeof source !== 'string' || !source)
return '' return ''
let text = source let text = source
// 剥离脚本/样式块 // 剥离脚本/样式块