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:
@@ -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>
|
||||||
|
|||||||
@@ -1,95 +1,91 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
||||||
|
|
||||||
interface IVoteCardOption {
|
interface IVoteCardOption {
|
||||||
id?: string
|
id ?: string
|
||||||
title?: string
|
title ?: string
|
||||||
checked?: boolean
|
checked ?: boolean
|
||||||
_uh_percent?: number
|
_uh_percent ?: number
|
||||||
[key: string]: unknown
|
[key : string] : unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IVoteCardData {
|
interface IVoteCardData {
|
||||||
metadata?: { name?: string, [key: string]: unknown }
|
metadata ?: { name ?: string, [key : string] : unknown }
|
||||||
spec?: {
|
spec ?: {
|
||||||
title?: string
|
title ?: string
|
||||||
remark?: string
|
remark ?: string
|
||||||
type?: string
|
type ?: string
|
||||||
timeLimit?: string
|
timeLimit ?: string
|
||||||
startDate?: string
|
startDate ?: string
|
||||||
endDate?: string
|
endDate ?: string
|
||||||
isVoted?: boolean
|
isVoted ?: boolean
|
||||||
_uh_type?: string
|
_uh_type ?: string
|
||||||
_uh_state?: { state: string, color: string, bgColor: string }
|
_uh_state ?: { state : string, color : string, bgColor : string }
|
||||||
options?: IVoteCardOption[]
|
options ?: IVoteCardOption[]
|
||||||
[key: string]: unknown
|
[key : string] : unknown
|
||||||
}
|
}
|
||||||
stats?: { voteCount?: number, voteDataList?: { id?: string, voteCount?: number }[] }
|
stats ?: { voteCount ?: number, voteDataList ?: { id ?: string, voteCount ?: number }[] }
|
||||||
[key: string]: unknown
|
[key : string] : unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
vote: IVoteCardData
|
vote : IVoteCardData
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
/** 跳转投票详情 */
|
/** 跳转投票详情 */
|
||||||
function handleToDetail() {
|
function handleToDetail() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
|
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化时间 */
|
/** 格式化时间 */
|
||||||
function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
|
function formatTime(date ?: string, fmt = 'yyyy-MM-dd HH:mm') : string {
|
||||||
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
|
<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 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 }}
|
||||||
>
|
</text>
|
||||||
{{ vote.spec._uh_type }}
|
<text v-if="vote.spec?._uh_state" class="rounded-md px-1.5 py-0.5 text-xs"
|
||||||
</text>
|
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]">
|
||||||
<text
|
{{ vote.spec._uh_state.state }}
|
||||||
v-if="vote.spec?._uh_state"
|
</text>
|
||||||
class="rounded-md px-1.5 py-0.5 text-[22rpx]"
|
<text v-if="vote.spec?.isVoted"
|
||||||
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]"
|
class="rounded-md bg-primary/15 px-1.5 py-0.5 text-xs text-primary">
|
||||||
>
|
已投票
|
||||||
{{ vote.spec._uh_state.state }}
|
</text>
|
||||||
</text>
|
</view>
|
||||||
<text v-if="vote.spec?.isVoted" class="rounded-md bg-primary/15 px-1.5 py-0.5 text-[22rpx] text-primary">
|
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
|
||||||
已投票
|
</view>
|
||||||
</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">
|
<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">
|
||||||
{{ vote.spec.remark }}
|
{{ vote.spec.remark }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 底部:时间 + 参与人数 -->
|
<!-- 底部:时间 + 参与人数 -->
|
||||||
<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>
|
||||||
@@ -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
@@ -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,8 +11,8 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
|
|
||||||
const appInfo = computed(() => {
|
const appInfo = computed(() => {
|
||||||
return {
|
return {
|
||||||
@@ -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>
|
||||||
@@ -95,4 +95,11 @@ const appConfigStore = useAppConfigStore()
|
|||||||
|
|
||||||
<uh-page-copyright />
|
<uh-page-copyright />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.uh-blur-xl {
|
||||||
|
filter: blur(20rpx);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+157
-162
@@ -1,184 +1,179 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
|
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
|
||||||
import { onPageScroll } from '@dcloudio/uni-app'
|
import { onPageScroll } from '@dcloudio/uni-app'
|
||||||
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 { checkAvatarUrl } from '@/utils/url'
|
import { checkAvatarUrl } from '@/utils/url'
|
||||||
import { formatTime } from '@/utils/formatTime'
|
import { formatTime } from '@/utils/formatTime'
|
||||||
import { markdownConfig } from '@/config/markdown'
|
import { markdownConfig } from '@/config/markdown'
|
||||||
|
|
||||||
definePage({
|
definePage({
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '联系博主',
|
navigationBarTitleText: '联系博主',
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
interface ISoical {
|
interface ISoical {
|
||||||
name: string
|
name : string
|
||||||
content: string
|
content : string
|
||||||
color: string
|
color : string
|
||||||
bgColor: string
|
bgColor : string
|
||||||
priority?: number
|
priority ?: number
|
||||||
visible?: boolean
|
visible ?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const { scrollY, updatePageScrollValue } = usePageScroll()
|
const { scrollY, updatePageScrollValue } = usePageScroll()
|
||||||
const appConfigStore = useAppConfigStore()
|
const appConfigStore = useAppConfigStore()
|
||||||
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
|
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
|
||||||
|
|
||||||
const bloggerInfo = computed(() => {
|
const bloggerInfo = computed(() => {
|
||||||
const blogger = authorConfig.value?.blogger as { nickname?: string, avatar?: string, description?: string, intro?: string } | undefined
|
const blogger = authorConfig.value?.blogger as { nickname ?: string, avatar ?: string, description ?: string, intro ?: string } | undefined
|
||||||
return {
|
return {
|
||||||
nickname: blogger?.nickname || '',
|
nickname: blogger?.nickname || '',
|
||||||
avatar: checkAvatarUrl(blogger?.avatar),
|
avatar: checkAvatarUrl(blogger?.avatar),
|
||||||
description: blogger?.description || '',
|
description: blogger?.description || '',
|
||||||
intro: blogger?.intro || '',
|
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 socialList = computed<Array<ISoical>>(() => {
|
||||||
const configured = socialConfig.value.items
|
const configured = socialConfig.value.items
|
||||||
if (!configured || !configured.length) {
|
if (!configured || !configured.length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return [...configured]
|
return [...configured]
|
||||||
.filter(item => item.visible && item.content.trim())
|
.filter(item => item.visible && item.content.trim())
|
||||||
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
|
.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()
|
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
|
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleOnClick(item: ISoical) {
|
function handleOnClick(item : ISoical) {
|
||||||
if (!item.content) { return }
|
if (!item.content) { return }
|
||||||
uni.setClipboardData({
|
uni.setClipboardData({
|
||||||
data: item.content,
|
data: item.content,
|
||||||
showToast: false,
|
showToast: false,
|
||||||
success: () => {
|
success: () => {
|
||||||
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
|
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const nowText = ref('')
|
const nowText = ref('')
|
||||||
let clock: ReturnType<typeof setInterval> | null = null
|
let clock : ReturnType<typeof setInterval> | null = null
|
||||||
function refreshNowText() {
|
function refreshNowText() {
|
||||||
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
|
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
|
||||||
}
|
}
|
||||||
refreshNowText()
|
refreshNowText()
|
||||||
clock = setInterval(refreshNowText, 1000)
|
clock = setInterval(refreshNowText, 1000)
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (clock) {
|
if (clock) {
|
||||||
clearInterval(clock)
|
clearInterval(clock)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onPageScroll((option: Page.PageScrollOption) => {
|
onPageScroll((option : Page.PageScrollOption) => {
|
||||||
updatePageScrollValue(option.scrollTop)
|
updatePageScrollValue(option.scrollTop)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
|
<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" />
|
<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> 收
|
</view>
|
||||||
</view>
|
<view class="text-md mt-2 text-gray-900 tracking-wider">
|
||||||
<view class="text-md mt-2 text-gray-900 tracking-wider">
|
素未谋面的朋友
|
||||||
素未谋面的朋友
|
</view>
|
||||||
</view>
|
<view class="mt-2 text-xs text-black/60">
|
||||||
<view class="mt-2 text-xs text-black/60">
|
展信安,见字如面。
|
||||||
展信安,见字如面。
|
</view>
|
||||||
</view>
|
<view class="mt-3 text-xs text-black/60">
|
||||||
<view class="mt-3 text-xs text-black/60">
|
自 · {{ bloggerInfo.nickname }}
|
||||||
自 · {{ bloggerInfo.nickname }}
|
</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" />
|
||||||
>
|
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
|
||||||
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
|
</view>
|
||||||
<text class="truncate text-xs font-normal">{{ bloggerInfo.nickname }}</text>
|
</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>
|
||||||
/>
|
<view class="w-full flex flex-col gap-y-3">
|
||||||
<template v-else>
|
<view class="text-md text-gray-900">
|
||||||
<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">
|
||||||
</view>
|
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
|
||||||
<view v-if="bloggerInfo.intro" class="text-sm text-gray-900">
|
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
||||||
<mp-html
|
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||||
lazy-load :domain="markdownConfig.domain ?? ''"
|
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
|
||||||
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
:show-language-name="true" copy-by-long-press />
|
||||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
</view>
|
||||||
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
|
<view v-else class="py-4 text-sm text-gray-600">
|
||||||
:show-language-name="true" copy-by-long-press
|
祝你早安,午安,晚安。每天都有好心情,生活愉快!
|
||||||
/>
|
</view>
|
||||||
</view>
|
<view class="mt-2 w-full flex flex-col items-end gap-y-3">
|
||||||
<view v-else class="py-4 text-sm text-gray-600">
|
<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="mt-2 w-full flex flex-col items-end gap-y-3">
|
</view>
|
||||||
<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="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 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
|
||||||
>
|
class="uh-global-card-glass uh-shadow-xs h-11 w-11 flex shrink-0 items-center justify-center border rounded-xl"
|
||||||
<view
|
:style="{ backgroundColor: item.bgColor, color: item.color }">
|
||||||
class="uh-global-card-glass uh-shadow-xs h-11 w-11 flex shrink-0 items-center justify-center border rounded-xl"
|
<text class="text-sm font-bold" :style="{ color: item.color }">
|
||||||
:style="{ backgroundColor: item.bgColor, color: item.color }"
|
{{ item.name ? item.name.charAt(0) : '' }}
|
||||||
>
|
</text>
|
||||||
<text class="text-sm font-bold" :style="{ color: item.color }">
|
</view>
|
||||||
{{ item.name ? item.name.charAt(0) : '' }}
|
<view class="min-w-0 flex flex-1 flex-col">
|
||||||
</text>
|
<text class="text-xs text-gray-500">{{ item.name }}</text>
|
||||||
</view>
|
<view class="mt-1 break-all text-xs text-gray-900">
|
||||||
<view class="min-w-0 flex flex-1 flex-col">
|
{{ item.content }}
|
||||||
<text class="text-xs text-gray-500">{{ item.name }}</text>
|
</view>
|
||||||
<view class="mt-1 break-all text-xs text-gray-900">
|
</view>
|
||||||
{{ item.content }}
|
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.uh-rotate-3 {
|
.uh-rotate-3 {
|
||||||
transform: rotate(3deg);
|
transform: rotate(3deg);
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
.uh-blur-xl {
|
||||||
|
filter: blur(20rpx);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -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,7 +275,8 @@
|
|||||||
.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 }}
|
||||||
|
|||||||
@@ -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!=='全部'">
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
// 剥离脚本/样式块
|
// 剥离脚本/样式块
|
||||||
|
|||||||
Reference in New Issue
Block a user