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>
<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>
精选分类
<template #right>
+79 -83
View File
@@ -1,95 +1,91 @@
<script lang="ts" setup>
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
interface IVoteCardOption {
id?: string
title?: string
checked?: boolean
_uh_percent?: number
[key: string]: unknown
}
interface IVoteCardOption {
id ?: string
title ?: string
checked ?: boolean
_uh_percent ?: number
[key : string] : unknown
}
interface IVoteCardData {
metadata?: { name?: string, [key: string]: unknown }
spec?: {
title?: string
remark?: string
type?: string
timeLimit?: string
startDate?: string
endDate?: string
isVoted?: boolean
_uh_type?: string
_uh_state?: { state: string, color: string, bgColor: string }
options?: IVoteCardOption[]
[key: string]: unknown
}
stats?: { voteCount?: number, voteDataList?: { id?: string, voteCount?: number }[] }
[key: string]: unknown
}
interface IVoteCardData {
metadata ?: { name ?: string, [key : string] : unknown }
spec ?: {
title ?: string
remark ?: string
type ?: string
timeLimit ?: string
startDate ?: string
endDate ?: string
isVoted ?: boolean
_uh_type ?: string
_uh_state ?: { state : string, color : string, bgColor : string }
options ?: IVoteCardOption[]
[key : string] : unknown
}
stats ?: { voteCount ?: number, voteDataList ?: { id ?: string, voteCount ?: number }[] }
[key : string] : unknown
}
const props = defineProps<{
vote: IVoteCardData
}>()
const props = defineProps<{
vote : IVoteCardData
}>()
/** 跳转投票详情 */
function handleToDetail() {
uni.navigateTo({
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
})
}
/** 跳转投票详情 */
function handleToDetail() {
uni.navigateTo({
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
})
}
/** 格式化时间 */
function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
}
/** 格式化时间 */
function formatTime(date ?: string, fmt = 'yyyy-MM-dd HH:mm') : string {
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
}
</script>
<template>
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
<!-- 头部:类型/状态/已投票 -->
<view class="flex items-center justify-between">
<view class="flex flex-wrap items-center gap-1">
<text
v-if="vote.spec?._uh_type"
class="rounded-md bg-secondary px-1.5 py-0.5 text-[22rpx] text-[#4d7c0f]"
>
{{ vote.spec._uh_type }}
</text>
<text
v-if="vote.spec?._uh_state"
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 }}
</text>
<text v-if="vote.spec?.isVoted" class="rounded-md bg-primary/15 px-1.5 py-0.5 text-[22rpx] text-primary">
已投票
</text>
</view>
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
</view>
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
<!-- 头部:类型/状态/已投票 -->
<view class="flex items-center justify-between">
<view class="flex flex-wrap items-center gap-1">
<text v-if="vote.spec?._uh_type"
class="rounded-md bg-secondary px-1.5 py-0.5 text-xs text-[#4d7c0f]">
{{ vote.spec._uh_type }}
</text>
<text v-if="vote.spec?._uh_state" class="rounded-md px-1.5 py-0.5 text-xs"
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]">
{{ vote.spec._uh_state.state }}
</text>
<text v-if="vote.spec?.isVoted"
class="rounded-md bg-primary/15 px-1.5 py-0.5 text-xs text-primary">
已投票
</text>
</view>
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
</view>
<!-- 标题 + 备注 -->
<view class="vote-title mt-2 text-[30rpx] font-bold text-gray-900">
{{ vote.spec?.title }}
</view>
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
{{ vote.spec.remark }}
</view>
<!-- 标题 + 备注 -->
<view class="vote-title mt-2 text-sm font-bold text-gray-900">
{{ vote.spec?.title }}
</view>
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
{{ vote.spec.remark }}
</view>
<!-- 底部:时间 + 参与人数 -->
<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>
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-[22rpx] text-gray-400">
开始:{{ formatTime(vote.spec?.startDate) }}
</text>
<text v-else class="text-[22rpx] text-gray-400">
结束:{{ formatTime(vote.spec?.endDate) }}
</text>
<text class="text-[22rpx] text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
</view>
</view>
<!-- 底部:时间 + 参与人数 -->
<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-xs text-gray-400">
结束:永久有效
</text>
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-xs text-gray-400">
开始:{{ formatTime(vote.spec?.startDate) }}
</text>
<text v-else class="text-xs text-gray-400">
结束:{{ formatTime(vote.spec?.endDate) }}
</text>
<text class="text-xs text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
</view>
</view>
</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 };
}
+38 -47
View File
@@ -1,22 +1,20 @@
import type { Ref } from 'vue'
import { ref } from 'vue'
/** 数据加载四态(取值与 DataLoadingStatusEnum 一致,二者可互相兼容) */
export type DataLoadingStatus = 'loading' | 'error' | 'empty' | 'success' | 'noNetwork'
import { ref } from 'vue';
import type { Ref } from 'vue';
import type { DataLoadingStatus } from './useDataLoadingStatus';
export interface IUseDataLoadingOptions<T> {
/** 自定义判空;默认:数组看长度、对象看键数、空值视为空 */
isEmpty?: (data: T) => boolean
/** 成功回调(数据就绪) */
onSuccess?: (data: T) => void
/** 失败回调(run 已捕获异常,不会向外抛出) */
onError?: (err: unknown) => void
/** 自定义判空;默认:数组看长度、对象看键数、空值视为空 */
isEmpty?: (data: T) => boolean;
/** 成功回调(数据就绪) */
onSuccess?: (data: T) => void;
/** 失败回调(run 已捕获异常,不会向外抛出) */
onError?: (err: unknown) => void;
}
export interface IUseDataLoadingReturn<T, P extends unknown[]> {
data: Ref<T | undefined>
status: Ref<DataLoadingStatus>
run: (...args: P) => Promise<T | undefined>
data: Ref<T | undefined>;
status: Ref<DataLoadingStatus>;
run: (...args: P) => Promise<T | undefined>;
}
/**
@@ -29,41 +27,34 @@ export interface IUseDataLoadingReturn<T, P extends unknown[]> {
* onLoad(() => run())
* onPullDownRefresh(async () => { await run(); uni.stopPullDownRefresh() })
*/
export function useDataLoading<T, P extends unknown[] = []>(
fetcher: (...args: P) => Promise<T>,
options: IUseDataLoadingOptions<T> = {},
): IUseDataLoadingReturn<T, P> {
const { isEmpty, onSuccess, onError } = options
export function useDataLoading<T, P extends unknown[] = []>(fetcher: (...args: P) => Promise<T>, options: IUseDataLoadingOptions<T> = {}): IUseDataLoadingReturn<T, P> {
const { isEmpty, onSuccess, onError } = options;
const data = ref<T | undefined>(undefined) as Ref<T | undefined>
const status = ref<DataLoadingStatus>('loading')
const data = ref<T | undefined>(undefined) as Ref<T | undefined>;
const status = ref<DataLoadingStatus>('loading');
function calcEmpty(value: T): boolean {
if (isEmpty)
return isEmpty(value)
if (Array.isArray(value))
return value.length === 0
if (value !== null && typeof value === 'object')
return Object.keys(value).length === 0
return value === undefined || value === null || value === ''
}
function calcEmpty(value: T): boolean {
if (isEmpty) return isEmpty(value);
if (Array.isArray(value)) return value.length === 0;
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> {
status.value = 'loading'
try {
const res = await fetcher(...args)
data.value = res
status.value = calcEmpty(res) ? 'empty' : 'success'
onSuccess?.(res)
return res
}
catch (err) {
console.error('[useDataLoading] 请求失败', err)
status.value = 'error'
onError?.(err)
return undefined
}
}
async function run(...args: P): Promise<T | undefined> {
status.value = 'loading';
try {
const res = await fetcher(...args);
data.value = res;
status.value = calcEmpty(res) ? 'empty' : 'success';
onSuccess?.(res);
return res;
} catch (err) {
console.error('[useDataLoading] 请求失败', err);
status.value = 'error';
onError?.(err);
return undefined;
}
}
return { data, status, run }
return { data, status, run };
}
+13 -6
View File
@@ -11,8 +11,8 @@
},
})
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const appInfo = computed(() => {
return {
@@ -53,8 +53,8 @@ const appConfigStore = useAppConfigStore()
<!-- 自定义导航 -->
<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 -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] 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)] uh-blur-xl" />
<view class="relative">
<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"
@click="copyText(link.copy, link.tip)">
<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` }">
<text class="text-sm font-bold" :style="{ color: link.tileColor }">{{ link.tileLetter }}</text>
</view>
<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">
{{ link.value }}
</view>
@@ -96,3 +96,10 @@ const appConfigStore = useAppConfigStore()
<uh-page-copyright />
</view>
</template>
<style scoped lang="scss">
.uh-blur-xl {
filter: blur(20rpx);
}
</style>
+156 -161
View File
@@ -1,184 +1,179 @@
<script lang="ts" setup>
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { onPageScroll } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkAvatarUrl } from '@/utils/url'
import { formatTime } from '@/utils/formatTime'
import { markdownConfig } from '@/config/markdown'
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { onPageScroll } from '@dcloudio/uni-app'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { usePageScroll } from '@/hooks/usePageScroll'
import { checkAvatarUrl } from '@/utils/url'
import { formatTime } from '@/utils/formatTime'
import { markdownConfig } from '@/config/markdown'
definePage({
style: {
navigationBarTitleText: '联系博主',
navigationStyle: 'custom',
},
})
definePage({
style: {
navigationBarTitleText: '联系博主',
navigationStyle: 'custom',
},
})
interface ISoical {
name: string
content: string
color: string
bgColor: string
priority?: number
visible?: boolean
}
interface ISoical {
name : string
content : string
color : string
bgColor : string
priority ?: number
visible ?: boolean
}
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
const bloggerInfo = computed(() => {
const blogger = authorConfig.value?.blogger as { nickname?: string, avatar?: string, description?: string, intro?: string } | undefined
return {
nickname: blogger?.nickname || '',
avatar: checkAvatarUrl(blogger?.avatar),
description: blogger?.description || '',
intro: blogger?.intro || '',
}
})
const bloggerInfo = computed(() => {
const blogger = authorConfig.value?.blogger as { nickname ?: string, avatar ?: string, description ?: string, intro ?: string } | undefined
return {
nickname: blogger?.nickname || '',
avatar: checkAvatarUrl(blogger?.avatar),
description: blogger?.description || '',
intro: blogger?.intro || '',
}
})
const socialConfig = computed(() => (authorConfig.value?.social as { items?: ISoical[] } | undefined) || {})
const socialConfig = computed(() => (authorConfig.value?.social as { items ?: ISoical[] } | undefined) || {})
const socialList = computed<Array<ISoical>>(() => {
const configured = socialConfig.value.items
if (!configured || !configured.length) {
return []
}
return [...configured]
.filter(item => item.visible && item.content.trim())
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
})
const socialList = computed<Array<ISoical>>(() => {
const configured = socialConfig.value.items
if (!configured || !configured.length) {
return []
}
return [...configured]
.filter(item => item.visible && item.content.trim())
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
})
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && item.content.trim()))
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && item.content.trim()))
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
watchEffect(() => {
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
})
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
watchEffect(() => {
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
})
function handleOnClick(item: ISoical) {
if (!item.content) { return }
uni.setClipboardData({
data: item.content,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
},
})
}
function handleOnClick(item : ISoical) {
if (!item.content) { return }
uni.setClipboardData({
data: item.content,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
},
})
}
const nowText = ref('')
let clock: ReturnType<typeof setInterval> | null = null
function refreshNowText() {
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
}
refreshNowText()
clock = setInterval(refreshNowText, 1000)
onUnmounted(() => {
if (clock) {
clearInterval(clock)
}
})
const nowText = ref('')
let clock : ReturnType<typeof setInterval> | null = null
function refreshNowText() {
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
}
refreshNowText()
clock = setInterval(refreshNowText, 1000)
onUnmounted(() => {
if (clock) {
clearInterval(clock)
}
})
onPageScroll((option: Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
onPageScroll((option : Page.PageScrollOption) => {
updatePageScrollValue(option.scrollTop)
})
</script>
<template>
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
<!-- 自定义导航 -->
<uh-navbar :scroll-y="scrollY" default-title="联系博主" title-color="text-gray-900" />
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
<!-- 自定义导航 -->
<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-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl -left-10" />
<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)] uh-blur-xl -left-10" />
<view
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="flex items-center gap-x-2 text-xs text-primary">
TO <text class="text-sm">·</text> 收
</view>
<view class="text-md mt-2 text-gray-900 tracking-wider">
素未谋面的朋友
</view>
<view class="mt-2 text-xs text-black/60">
展信安,见字如面。
</view>
<view class="mt-3 text-xs text-black/60">
自 · {{ bloggerInfo.nickname }}
</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"
>
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
</view>
</view>
<view
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="flex items-center gap-x-2 text-xs text-primary">
TO <text class="text-sm">·</text> 收
</view>
<view class="text-md mt-2 text-gray-900 tracking-wider">
素未谋面的朋友
</view>
<view class="mt-2 text-xs text-black/60">
展信安,见字如面。
</view>
<view class="mt-3 text-xs text-black/60">
自 · {{ bloggerInfo.nickname }}
</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">
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
</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">
<uh-data-loading
v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
empty-text="暂无联系方式" empty-sub-text=""
/>
<template v-else>
<view class="w-full flex flex-col gap-y-3">
<view class="text-md text-gray-900">
展信安:
</view>
<view v-if="bloggerInfo.intro" class="text-sm text-gray-900">
<mp-html
lazy-load :domain="markdownConfig.domain ?? ''"
:loading-img="markdownConfig.loadingGif" scroll-table selectable
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
:show-language-name="true" copy-by-long-press
/>
</view>
<view v-else class="py-4 text-sm text-gray-600">
祝你早安,午安,晚安。每天都有好心情,生活愉快!
</view>
<view class="mt-2 w-full flex flex-col items-end gap-y-3">
<text class="text-md text-gray-900 font-semibold">{{ bloggerInfo.nickname }}</text>
<text class="text-xs text-black/60">{{ nowText }}</text>
</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">
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
empty-text="暂无联系方式" empty-sub-text="" />
<template v-else>
<view class="w-full flex flex-col gap-y-3">
<view class="text-md text-gray-900">
展信安:
</view>
<view v-if="bloggerInfo.intro" class="text-sm text-gray-900">
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
:loading-img="markdownConfig.loadingGif" scroll-table selectable
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
:show-language-name="true" copy-by-long-press />
</view>
<view v-else class="py-4 text-sm text-gray-600">
祝你早安,午安,晚安。每天都有好心情,生活愉快!
</view>
<view class="mt-2 w-full flex flex-col items-end gap-y-3">
<text class="text-md text-gray-900 font-semibold">{{ bloggerInfo.nickname }}</text>
<text class="text-xs text-black/60">{{ nowText }}</text>
</view>
</view>
<view class="box-border w-full flex flex-col gap-y-2 border-t border-gray-200 border-t-dashed pt-4">
<view class="text-md mb-2 text-gray-900">
若有意,可依此觅:
</view>
<view
v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
@click="handleOnClick(item)"
>
<view
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 }"
>
<text class="text-sm font-bold" :style="{ color: item.color }">
{{ item.name ? item.name.charAt(0) : '' }}
</text>
</view>
<view class="min-w-0 flex flex-1 flex-col">
<text class="text-xs text-gray-500">{{ item.name }}</text>
<view class="mt-1 break-all text-xs text-gray-900">
{{ item.content }}
</view>
</view>
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
</view>
</view>
</template>
</view>
</view>
<view class="box-border w-full flex flex-col gap-y-2 border-t border-gray-200 border-t-dashed pt-4">
<view class="text-md mb-2 text-gray-900">
若有意,可依此觅:
</view>
<view v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
@click="handleOnClick(item)">
<view
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 }">
<text class="text-sm font-bold" :style="{ color: item.color }">
{{ item.name ? item.name.charAt(0) : '' }}
</text>
</view>
<view class="min-w-0 flex flex-1 flex-col">
<text class="text-xs text-gray-500">{{ item.name }}</text>
<view class="mt-1 break-all text-xs text-gray-900">
{{ item.content }}
</view>
</view>
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
</view>
</view>
</template>
</view>
</view>
</template>
<style scoped lang="scss">
.uh-rotate-3 {
transform: rotate(3deg);
}
.uh-rotate-3 {
transform: rotate(3deg);
}
.uh-blur-xl {
filter: blur(20rpx);
}
</style>
+19 -18
View File
@@ -127,9 +127,9 @@
<!-- 内容区域 -->
<view class="box-border flex flex-col gap-y-6 p-3">
<!-- 顶部分段器:布局 / 功能 -->
<view class="uh-global-card-glass flex rounded-full p-1">
<view v-for="tab in SETTING_TABS" :key="tab.key" class="flex-1 rounded-full py-1.5 text-center text-sm"
:class="activeTab === tab.key ? 'bg-primary font-bold' : 'text-gray-500'"
<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-lg py-2 text-center text-2xs"
:class="activeTab === tab.key ? 'bg-primary font-medium' : 'text-gray-500'"
@click="activeTab = tab.key">
{{ tab.label }}
</view>
@@ -139,24 +139,24 @@
<template v-if="activeTab === 'layout'">
<view v-for="group in layoutGroups" :key="group.key" class="flex flex-col gap-y-3">
<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"
class="pick-row flex items-center justify-between px-4 py-4"
:class="index < group.rows.length - 1 ? 'border-b border-black/5' : ''"
@click="handleOpenEnum(row)">
<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">
<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
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 class="row-value flex items-center gap-2">
<text class="value-text text-[26rpx] text-gray-400">{{ row.displayValue }}</text>
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" />
<view class="flex items-center gap-2 text-gray-400">
<text class="text-xs">{{ row.displayValue }}</text>
<wd-icon name="arrow-right" size="24rpx" />
</view>
</view>
</view>
@@ -172,15 +172,15 @@
<text class="text-2xs text-gray-400">一些常用的功能性设置</text>
</template>
</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">
<!-- 布尔项:内联分段器(默认 / 开 / 关) -->
<view v-if="row.kind === 'bool'" class="box-border p-3"
:class="index < featureRows.length - 1 ? 'border-b border-black/5' : ''">
<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">
<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
class="rounded-full bg-secondary px-2 py-1 text-xs text-gray-900 leading-none">
已自定义
@@ -225,9 +225,9 @@
</template>
</view>
</view>
<view class="row-value flex items-center gap-2">
<text class="value-text text-[26rpx] text-gray-400">{{ row.displayValue }}</text>
<wd-icon name="arrow-right" size="12px" color="#c8c2b4" />
<view class="flex items-center gap-2 text-gray-400">
<text class="text-xs">{{ row.displayValue }}</text>
<wd-icon name="arrow-right" size="24rpx" />
</view>
</view>
</template>
@@ -236,7 +236,7 @@
</template>
<!-- 底部操作栏-->
<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>
</view>
@@ -275,7 +275,8 @@
.wd-picker-view__mask {
background: transparent !important;
}
.wd-picker-view__roller{
.wd-picker-view__roller {
border-radius: 16rpx !important;
}
}
+1 -1
View File
@@ -357,7 +357,7 @@
</view>
<view class="flex flex-col gap-2">
<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'"
@click="handleSelectFilter(opt)">
{{ opt.label }}
+6 -5
View File
@@ -8,8 +8,8 @@
import { usePageScroll } from '@/hooks/usePageScroll'
import { sleep } from '@/utils/common'
import { t } from '@/locale'
import { isWechat } from '@/utils/platform'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { useCustomNavbarPlaceholder } from '@/hooks/useCustomNavbarPlaceholder'
import type { IPhoto, IPhotoGroup } from '@/api/types/halo'
definePage({
@@ -20,6 +20,7 @@
},
})
const { height: offsetTop } = useCustomNavbarPlaceholder()
const { scrollY, updatePageScrollValue } = usePageScroll()
const appConfigStore = useAppConfigStore()
const haloConfigs = computed(() => appConfigStore.configs)
@@ -221,11 +222,11 @@
:checking="checking" @on-refresh="checkPluginAvailable" />
<template v-else>
<wd-sticky v-if="category.list.length!==0" class="w-full" :offset-top="isWechat?56:0">
<scroll-view :scroll-x="true" class="w-full whitespace-nowrap pt-2">
<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-1 ml-3 inline-flex border rounded-2xl px-4 py-1.5 text-2xs"
:class="{ 'bg-primary text-gray-900 font-bold': index === category.activeIndex }"
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-semibold': index === category.activeIndex }"
@click="handleGetDataByCategory(index, cate)">
{{ 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
/** 取文章摘要文本(excerpt 优先,兜底从正文抽取) */
/** 取文章摘要文本(excerpt 优先,兜底从正文抽取;候选字段可能被接口返回非字符串,逐个过滤) */
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 原文(可为空)
*/
export function htmlToPlainText(source?: string): string {
if (!source)
if (typeof source !== 'string' || !source)
return ''
let text = source
// 剥离脚本/样式块