mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
style: 优化多处UI细节与代码结构
1. 调整多处文字大小与间距样式统一视觉 2. 优化导航栏模糊效果与布局 3. 重构评论项头像加载逻辑,增加昵称首字占位兜底 4. 重写我的页面代码结构与布局样式 5. 清理评论列表冗余代码与格式化模板
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
pinned: 'right-3 top-3',
|
||||
},
|
||||
image_left: {
|
||||
container: 'flex gap-x-3 !p-2',
|
||||
container: 'flex gap-x-3 !p-3',
|
||||
cover: 'shrink-0 !w-36 !h-24',
|
||||
contentWrapper: 'w-0 flex-1 justify-between',
|
||||
footer: 'flex items-center justify-between',
|
||||
@@ -79,10 +79,10 @@
|
||||
time: '!hidden',
|
||||
tagCategory: '!hidden',
|
||||
visits: '',
|
||||
pinned: 'left-3 top-3',
|
||||
pinned: 'left-4 top-4',
|
||||
},
|
||||
image_right: {
|
||||
container: 'flex gap-x-3 !p-2',
|
||||
container: 'flex gap-x-3 !p-3',
|
||||
cover: 'order-2 shrink-0 !w-36 !h-24',
|
||||
contentWrapper: 'order-1 w-0 flex-1 justify-between',
|
||||
footer: 'flex items-center justify-between',
|
||||
@@ -93,7 +93,7 @@
|
||||
time: '!hidden',
|
||||
tagCategory: '!hidden',
|
||||
visits: '',
|
||||
pinned: 'right-3 top-3',
|
||||
pinned: 'right-4 top-4',
|
||||
},
|
||||
}) as Record<CardLayout, CardLayoutClasses>)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { checkAvatarUrl } from '@/utils/url'
|
||||
@@ -40,6 +40,26 @@
|
||||
|
||||
const avatar = computed(() => checkAvatarUrl(props.comment.spec.owner.avatar))
|
||||
|
||||
/** 用户是否提供了头像(无头像时用昵称首字占位) */
|
||||
const hasAvatar = computed(() => !!props.comment.spec.owner.avatar?.trim())
|
||||
|
||||
/** 昵称首字(头像占位) */
|
||||
const avatarText = computed(() => {
|
||||
const name = props.comment.spec.owner.displayName?.trim()
|
||||
return name ? Array.from(name)[0] : '?'
|
||||
})
|
||||
|
||||
/** 头像加载失败标记(失败后回退首字占位) */
|
||||
const avatarError = ref(false)
|
||||
|
||||
/** 是否渲染图片头像(有头像且未加载失败) */
|
||||
const showImage = computed(() => hasAvatar.value && !avatarError.value)
|
||||
|
||||
/** 头像地址变化时重置加载失败标记(组件复用时) */
|
||||
watch(() => props.comment.spec.owner.avatar, () => {
|
||||
avatarError.value = false
|
||||
})
|
||||
|
||||
/** 引用回复标识(被引用人在父级已加载回复映射中可查到时显示) */
|
||||
const quoteReplyText = computed(() => {
|
||||
const quoteName = props.comment.spec.quoteReply
|
||||
@@ -61,7 +81,8 @@
|
||||
})
|
||||
|
||||
function handleOnImageError() {
|
||||
// 头像加载失败时回退默认头像(由 checkAvatarUrl 兜底,此处保持简单)
|
||||
// 头像加载失败时回退昵称首字占位
|
||||
avatarError.value = true
|
||||
}
|
||||
|
||||
function handleOnCopy() {
|
||||
@@ -82,8 +103,12 @@
|
||||
'pl-10':props.isChild,
|
||||
}">
|
||||
<view class="flex shrink-0">
|
||||
<image class="box-border h-10 w-10 shrink-0 rounded-full border border-white uh-shadow-xs border-solid" :src="avatar" mode="aspectFill"
|
||||
@error="handleOnImageError" />
|
||||
<image v-if="showImage"
|
||||
class="box-border h-10 w-10 shrink-0 rounded-full border border-white uh-shadow-xs border-solid" :src="avatar"
|
||||
mode="aspectFill" @error="handleOnImageError" />
|
||||
<view v-else class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[#bbe52a6b]">
|
||||
<text class="text-sm font-bold text-gray-900">{{ avatarText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-1 box-border pl-2">
|
||||
<view class="text-sm text-gray-500">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { getPostCommentList, getPostCommentReplyList } from '@/api/halo'
|
||||
import { checkAvatarUrl } from '@/utils/url'
|
||||
import type { IComment, ICommentListRes, ICommentReply } from '@/api/types/halo'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -54,11 +53,7 @@
|
||||
try {
|
||||
const res = await getPostCommentList({ ...queryParams.value })
|
||||
result.value = res.data
|
||||
dataList.value = res.data.items.map((item) => {
|
||||
// todo:临时
|
||||
item.spec.owner.avatar = checkAvatarUrl(item.spec.owner.avatar ?? 'https://api.dicebear.com/10.x/adventurer-neutral/svg')
|
||||
return item
|
||||
})
|
||||
dataList.value = res.data.items
|
||||
// 列表刷新后清空展开缓存,保证回复区展示最新数据
|
||||
expanded.clear()
|
||||
repliesMap.clear()
|
||||
@@ -217,10 +212,7 @@
|
||||
<uh-section-title>
|
||||
评论列表
|
||||
<template #right>
|
||||
<view class="flex items-center gap-1.5 text-xs text-gray-500 font-normal" @click="handleGetData">
|
||||
<wd-icon name="refresh" size="28rpx" />
|
||||
<text class="">刷新</text>
|
||||
</view>
|
||||
<text class="text-xs text-gray-500 font-normal" @click="handleGetData">刷新</text>
|
||||
</template>
|
||||
</uh-section-title>
|
||||
|
||||
@@ -246,11 +238,11 @@
|
||||
<view v-if="dataList.length === 0" class="py-12">
|
||||
<view class="flex flex-col items-center">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-confused" size="100rpx" class="text-primary" />
|
||||
<text class="mt-2 text-sm text-gray-500">暂无评论</text>
|
||||
<text class="mt-2 text-xs text-gray-500">暂无评论</text>
|
||||
<view v-if="disallowComment" class="mt-2 text-xs text-red-400">
|
||||
文章已开启禁止评论
|
||||
</view>
|
||||
<view v-else class="mt-2 bg-primary text-black text-sm px-4 py-1.5 rounded-lg"
|
||||
<view v-else class="mt-2 bg-primary text-black text-xs px-4 py-1.5 rounded-lg"
|
||||
@click="handleToComment()">
|
||||
抢沙发
|
||||
</view>
|
||||
@@ -279,7 +271,8 @@
|
||||
class="mt-2 ml-10 text-xs text-red-400" @click="loadReplies(comment)">
|
||||
回复加载失败,点击重试
|
||||
</view>
|
||||
<view v-else-if="getRepliesState(comment)?.status === 'loading' && getRepliesState(comment)?.list.length === 0"
|
||||
<view
|
||||
v-else-if="getRepliesState(comment)?.status === 'loading' && getRepliesState(comment)?.list.length === 0"
|
||||
class="mt-2 ml-10 text-xs text-gray-400">
|
||||
回复加载中...
|
||||
</view>
|
||||
@@ -288,8 +281,8 @@
|
||||
:key="childComment.metadata.name" :use-content-bg="false" :is-child="true"
|
||||
:comment="childComment" :post-name="postName"
|
||||
:disallow-comment="disallowComment"
|
||||
:quote-reply-map="buildQuoteReplyMap(comment)"
|
||||
@on-copy="handleCopyContent" @on-comment="(d) => handleToComment(d, comment)"
|
||||
:quote-reply-map="buildQuoteReplyMap(comment)" @on-copy="handleCopyContent"
|
||||
@on-comment="(d) => handleToComment(d, comment)"
|
||||
@on-detail="handleShowCommentDetail" />
|
||||
|
||||
<!-- 加载更多(响应 hasNext) -->
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
<!-- 文案区 -->
|
||||
<view class="relative z-2 flex flex-col items-center">
|
||||
<view class="flex items-center justify-center text-sm font-bold" :class="statusScene.mainTextClass">
|
||||
<view class="flex items-center justify-center text-2xs font-medium" :class="statusScene.mainTextClass">
|
||||
<text>{{ statusScene.mainText }}</text>
|
||||
<view v-if="isLoading" class="ml-1 flex items-end gap-1">
|
||||
<view v-for="n in 3" :key="n" class="typing-dot bg-primary"
|
||||
@@ -117,7 +117,7 @@
|
||||
{{ statusScene.subText }}
|
||||
</text>
|
||||
<view v-if="props.useRefreshButton" class="mt-4">
|
||||
<uh-button :custom-class="'uh-global-card-glass uh-shadow-xs border' + sizeClasses.button"
|
||||
<uh-button :custom-class="'uh-global-card-glass text-xs py-2 uh-shadow-xs border' + sizeClasses.button"
|
||||
@click="emit('refresh')">
|
||||
刷新试试
|
||||
</uh-button>
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
</swiper>
|
||||
<view v-if="currentBanner"
|
||||
class="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-y-2 bg-white/5 backdrop-blur-[2rpx]">
|
||||
<text class="text-sm text-gray-900 font-bold bg-secondary px-3 py-0.5 rounded-xl">
|
||||
<text class="text-2xs text-gray-900 font-bold bg-secondary px-3 py-1 rounded-xl">
|
||||
{{ currentBanner.title }}
|
||||
</text>
|
||||
<text
|
||||
@@ -122,7 +122,7 @@
|
||||
<view class="absolute bottom-0 left-0 right-0 h-12 w-full bg-gradient-to-b from-white/0 to-page" />
|
||||
<view class="absolute left-0 right-0 z-10 flex items-center justify-center uh-translate-y-n6">
|
||||
<view
|
||||
class="uh-global-card-glass border w-4/5 rounded-full px-4 py-2 text-sm text-gray-600 flex items-center justify-center gap-x-2"
|
||||
class="uh-global-card-glass border w-4/5 rounded-full px-4 py-2.5 text-2xs text-gray-600 flex items-center justify-center gap-x-2"
|
||||
@click="handleToSearch()">
|
||||
<wd-icon name="search-line" size="32rpx"></wd-icon>
|
||||
<text>哈喽,想看些什么 <text class="bg-secondary rounded-xl px-1">{ 内容 }</text> 呢~</text>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<image :src="category.spec.cover" class="w-full h-full" mode="aspectFill" lazy-load />
|
||||
<view class="absolute bottom-0 left-0 h-16 w-full bg-gradient-to-b from-black/0 to-black/30" />
|
||||
<view class="absolute left-2 bottom-2 flex z-2 flex-col text-left">
|
||||
<text class="text-2xs font-semibold">
|
||||
<text class="text-xs font-semibold">
|
||||
{{ category.spec.displayName }}
|
||||
</text>
|
||||
<text class="mt-1 text-xs text-gray-200">共 {{ category.postCount ?? 0 }} 篇</text>
|
||||
|
||||
@@ -27,10 +27,11 @@
|
||||
backClass: 'text-gray-900',
|
||||
})
|
||||
|
||||
const maxAlpha = ref(0.65)
|
||||
const maxAlpha = ref(0.75)
|
||||
const customStyle = computed(() => {
|
||||
const alpha = Math.min(props.scrollY / 360, maxAlpha.value)
|
||||
return {
|
||||
backdropFilter: 'blur(2rpx)',
|
||||
backgroundColor: `rgba(255, 255, 255, ${alpha})`,
|
||||
}
|
||||
})
|
||||
@@ -88,7 +89,7 @@
|
||||
|
||||
<template>
|
||||
<view class="fixed left-0 top-0 z-100 box-border w-full pt-safe" :class="customCalss" :style="[customStyle]">
|
||||
<view class="box-border h-[46px] w-full flex items-center gap-x-4 px-3" style="backdrop-filter: blur(2rpx);">
|
||||
<view class="box-border h-[46px] w-full flex items-center gap-x-4 px-3">
|
||||
<!-- 左边 -->
|
||||
<view class="min-w-18 shrink-0" @click="handleBack()">
|
||||
<view v-if="props.useBack"
|
||||
@@ -101,7 +102,7 @@
|
||||
</view>
|
||||
<!-- 中间 -->
|
||||
<view class="flex-1 truncate text-center font-bold transition-colors duration-300" :class="titleColorClass">
|
||||
{{props.scrollY}} <slot> {{ visibleTitle }} </slot>
|
||||
<slot> {{ visibleTitle }} </slot>
|
||||
</view>
|
||||
<!-- 右边 -->
|
||||
<view class="min-w-18 shrink-0">
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<view class="text-sm font-bold leading-snug text-gray-900">
|
||||
{{ notice.title }}
|
||||
</view>
|
||||
<view v-if="notice.summary" class="mt-3 text-2xs leading-relaxed text-gray-600">
|
||||
<view v-if="notice.summary" class="mt-3 text-xs leading-relaxed text-gray-900">
|
||||
{{ notice.summary }}
|
||||
</view>
|
||||
<view v-if="notice.publishTime" class="mt-3 text-xs text-gray-600">
|
||||
@@ -119,7 +119,7 @@
|
||||
<view class="text-xs text-gray-600 " @click="handleDismissForever">
|
||||
今日不再提醒
|
||||
</view>
|
||||
<uh-button custom-class="font-semibold text-xs" @click="handleViewAll">
|
||||
<uh-button custom-class="text-xs" @click="handleViewAll">
|
||||
查看全文 →
|
||||
</uh-button>
|
||||
</view>
|
||||
|
||||
@@ -31,24 +31,24 @@
|
||||
class="max-w-3/5 mx-auto my-auto box-border flex flex-col items-center justify-center gap-6 text-sm"
|
||||
:class="props.customClass">
|
||||
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-cry" size="160rpx"></wd-icon>
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-cry" size="140rpx"></wd-icon>
|
||||
|
||||
<view class="box-border text-lg text-gray-900 font-bold">
|
||||
<view class="box-border text-sm text-gray-900 font-bold">
|
||||
{{ pluginInfo.name }}
|
||||
</view>
|
||||
|
||||
<view v-if="errorText" class=" text-yellow-500 text-sm">
|
||||
<view v-if="errorText" class="text-yellow-500 text-2xs">
|
||||
{{ errorText }}
|
||||
</view>
|
||||
|
||||
<view class="w-full flex flex-col gap-y-4">
|
||||
<uh-button custom-class="!rounded-full py-2 !uh-shadow-xs" @click="handleRefresh()">
|
||||
<uh-button custom-class="!rounded-full text-xs py-2 !uh-shadow-xs" @click="handleRefresh()">
|
||||
{{props.checking?'正在刷新':'刷新试试'}}
|
||||
</uh-button>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<!-- 微信端客服会话只能由原生 button 的 open-type="contact" 唤起,故此处不用 uh-button(view 实现) -->
|
||||
<button
|
||||
class="uh-contact-btn bg-white py-2 px-4 !rounded-full text-black text-sm leading-none flex items-center justify-center"
|
||||
class="uh-contact-btn w-full bg-white py-2.5 px-4 !rounded-full text-black text-xs leading-none flex items-center justify-center"
|
||||
open-type="contact" hover-class="none">提交反馈</button>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
|
||||
@@ -459,7 +459,7 @@
|
||||
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus"
|
||||
@refresh="handleGetData()" />
|
||||
|
||||
<view v-else class="box-border pt-72">
|
||||
<view v-else class="box-border pt-72 pb-4">
|
||||
<!-- 顶部背景封面区域 -->
|
||||
<view class="fixed left-0 top-0 h-72 w-full">
|
||||
<image v-if="result?.spec.cover" :src="result.spec.cover" class="h-full w-full" mode="aspectFill" />
|
||||
@@ -567,7 +567,7 @@
|
||||
<view v-if="postDetailConfig?.copyrightEnabled" class="box-border px-2 mb-3">
|
||||
<view class="uh-global-card-glass uh-shadow-xs rounded-xl p-3">
|
||||
<uh-section-title>版权声明</uh-section-title>
|
||||
<view class="mt-3 flex flex-col gap-y-2 text-gray-600 text-2xs">
|
||||
<view class="mt-3 flex flex-col gap-y-2 text-gray-600 text-xs">
|
||||
<view v-if="postDetailConfig.copyrightAuthor" class="leading-5">
|
||||
版权归属:{{ postDetailConfig.copyrightAuthor }}
|
||||
</view>
|
||||
@@ -592,26 +592,26 @@
|
||||
</view>
|
||||
|
||||
<!-- 悬浮操作 -->
|
||||
<view class="fixed bottom-2 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||
<view class="fixed bottom-0 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||
<view
|
||||
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
||||
<view
|
||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||
:class="[hasUpvoted()?'text-primary':'text-gray-900']" @click="handleDoLikesClick">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="36rpx" />
|
||||
<text class="shrink-0 text-3xs font-semibold">点赞</text>
|
||||
<text class="shrink-0 text-xs font-semibold">点赞</text>
|
||||
</view>
|
||||
<view v-if="calcIsShowComment"
|
||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||
@click="handleToComment()">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="36rpx" />
|
||||
<text class="shrink-0 text-3xs text-gray-900 font-semibold">评论</text>
|
||||
<text class="shrink-0 text-xs text-gray-900 font-semibold">评论</text>
|
||||
</view>
|
||||
<view
|
||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||
@click="handleTogglePostFavorite">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
|
||||
<text class="shrink-0 text-3xs font-semibold"
|
||||
<text class="shrink-0 text-xs font-semibold"
|
||||
:class="[hasFavorited()?'text-primary':'text-gray-900']">
|
||||
{{ hasFavorited() ? '已收藏' : '收藏' }}
|
||||
</text>
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
<uh-data-loading v-if="status !== 'success'" :loading-status="status" min-height="60vh" error-text="瞬间内容加载失败"
|
||||
empty-text="瞬间不存在或已被删除" @refresh="loadMoment" />
|
||||
|
||||
<view v-else-if="moment" class="box-border px-3 pt-2 pb-12">
|
||||
<view v-else-if="moment" class="box-border px-3 pt-2 pb-14">
|
||||
<view class="mb-3 uh-global-card-glass uh-shadow-xs overflow-hidden rounded-2xl box-border pb-4">
|
||||
<!-- 刊头:大字日期 -->
|
||||
<view v-if="moment.spec.releaseTime" class="px-4 pt-4">
|
||||
@@ -303,17 +303,17 @@
|
||||
<image class="h-[80rpx] w-[80rpx] shrink-0 rounded-full"
|
||||
:src="checkAvatarUrl(moment.owner?.avatar || bloggerInfo.avatar)" mode="aspectFill" />
|
||||
<view class="ml-3 flex flex-col">
|
||||
<view class="text-[30rpx] text-[#5c7c0f] font-bold">
|
||||
<view class="text-md text-gray-600 font-medium">
|
||||
{{ moment.owner?.displayName || bloggerInfo.nickname }}
|
||||
</view>
|
||||
<view class="mt-0.5 text-[22rpx] text-gray-400">
|
||||
<view class="mt-0.5 text-xs text-gray-400">
|
||||
记录了这美好的一刻
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 正文 -->
|
||||
<view class="content px-4 mt-6 text-gray-900 text-sm">
|
||||
<view class="content px-4 mt-6 text-gray-900 text-2xs">
|
||||
<mp-html lazy-load :domain="markdownConfig.domain ?? ''" :loading-img="markdownConfig.loadingGif"
|
||||
scroll-table selectable :tag-style="markdownConfig.tagStyle"
|
||||
:container-style="markdownConfig.containStyle" :content="moment.spec.newHtml || ''"
|
||||
@@ -368,7 +368,7 @@
|
||||
|
||||
<!-- 悬浮操作 -->
|
||||
<view v-if="moment"
|
||||
class="fixed bottom-8 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||
class="fixed bottom-0 left-1/2 z-10 flex items-center justify-center pb-safe uh-translate-x-center">
|
||||
<view
|
||||
class="uh-global-card-glass box-border flex items-center justify-center gap-2 border rounded-full p-1 text-primary">
|
||||
<!-- 点赞 -->
|
||||
@@ -376,21 +376,21 @@
|
||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||
:class="[hasUpvoted()?'text-primary':'text-gray-900']" @click="handleDoLikesClick">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-kiss-" size="36rpx" />
|
||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">点赞</text>
|
||||
<text class="shrink-0 text-xs text-gray-900 font-semibold">点赞</text>
|
||||
</view>
|
||||
<!-- 评论 -->
|
||||
<view v-if="moment.spec.allowComment"
|
||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||
@click="handleToComment()">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-thinking" size="36rpx" />
|
||||
<text class="shrink-0 text-sm text-gray-900 font-semibold">评论</text>
|
||||
<text class="shrink-0 text-xs text-gray-900 font-semibold">评论</text>
|
||||
</view>
|
||||
<!-- 收藏 -->
|
||||
<view
|
||||
class="uh-global-card-glass box-border h-[72rpx] flex flex-1 items-center justify-center gap-x-1 border rounded-full px-4 shadow-none"
|
||||
@click="handleToggleMomentFavorite">
|
||||
<wd-icon class-prefix="uhemoji-icon" name="-smile-" size="36rpx" />
|
||||
<text class="shrink-0 text-sm font-semibold"
|
||||
<text class="shrink-0 text-xs font-semibold"
|
||||
:class="[momentFavorited ? 'text-primary' : 'text-gray-900']">{{ momentFavorited ? '已收藏' : '收藏' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -214,12 +214,12 @@
|
||||
<!-- 自定义导航 -->
|
||||
<uh-navbar :scroll-y="scrollY" default-title="内容搜索" title-color="text-gray-900" />
|
||||
|
||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" :plugin-id="pluginId" :error-text="tips"
|
||||
<uh-plugin-unavailable v-if="!uniHaloPluginAvailable" custom-class="min-h-[80vh]" :plugin-id="pluginId" :error-text="tips"
|
||||
:checking="checking" @on-refresh="handlePluginRefresh" />
|
||||
|
||||
<template v-else>
|
||||
<!-- 顶部搜索框-->
|
||||
<wd-sticky class="">
|
||||
<wd-sticky>
|
||||
<view class="w-screen box-border px-3 py-2">
|
||||
<view class="box-border uh-global-card-glass h-9 flex items-center gap-3 rounded-full pl-1 pr-3">
|
||||
<wd-icon name="search" size="16px" />
|
||||
|
||||
@@ -4,9 +4,7 @@ import { onPullDownRefresh, onShow } from '@dcloudio/uni-app'
|
||||
import { getBlogStatistics } from '@/api/halo'
|
||||
import { useAppConfigStore } from '@/store/appConfig'
|
||||
import { useFavoritesStore } from '@/store/favorites'
|
||||
import { NeedPluginIds } from '@/hooks/usePluginAvailable'
|
||||
import { checkAvatarUrl, checkImageUrl } from '@/utils/url'
|
||||
import { checkHasAdminLogin } from '@/utils/auth'
|
||||
import { t } from '@/locale'
|
||||
import type { IBlogStats } from '@/api/types/halo'
|
||||
|
||||
@@ -22,18 +20,6 @@ const appConfigStore = useAppConfigStore()
|
||||
const favoritesStore = useFavoritesStore()
|
||||
const haloConfigs = computed(() => appConfigStore.configs)
|
||||
const calcAuditModeEnabled = computed(() => appConfigStore.auditModeEnabled)
|
||||
/** 数据看板插件可用性(供导航项显隐判断,参考 gallery 对象传参模式) */
|
||||
const { check: checkDataVisualPlugin } = usePluginAvailable({
|
||||
pluginId: NeedPluginIds.PluginDataStatistics,
|
||||
})
|
||||
/** 投票插件可用性(投票中心导航项显隐) */
|
||||
const { check: checkVotePluginAvailable } = usePluginAvailable({
|
||||
pluginId: NeedPluginIds.PluginVote,
|
||||
})
|
||||
/** 链接插件可用性(友情链接导航项显隐) */
|
||||
const { check: checkLinksPluginAvailable } = usePluginAvailable({
|
||||
pluginId: NeedPluginIds.PluginLinks,
|
||||
})
|
||||
|
||||
/* ---------------- 计算属性 ---------------- */
|
||||
const bloggerInfo = computed(() => {
|
||||
@@ -106,7 +92,7 @@ const configuredFeatures = computed(() => {
|
||||
})
|
||||
|
||||
const navList = ref<INavItem[]>([])
|
||||
|
||||
const featureMode = ref<'base' | 'list'>('base')
|
||||
/** 分组渲染(过滤后空组整组隐藏;组标题对齐插件端:常用功能/其他功能) */
|
||||
const calcNavGroups = computed(() => {
|
||||
const visible = navList.value.filter(n => n.show)
|
||||
@@ -119,6 +105,13 @@ const calcNavGroups = computed(() => {
|
||||
.filter(group => group.items.length > 0)
|
||||
})
|
||||
|
||||
const commonFeatures = computed(() => {
|
||||
return navList.value.filter(f => f.show && f.group === 'blog')
|
||||
})
|
||||
const otherFeatures = computed(() => {
|
||||
return navList.value.filter(f => f.show && f.group === 'more')
|
||||
})
|
||||
|
||||
/* ---------------- 功能导航 ---------------- */
|
||||
|
||||
async function handleGetNavList() {
|
||||
@@ -147,12 +140,6 @@ async function handleGetNavList() {
|
||||
]
|
||||
return
|
||||
}
|
||||
|
||||
const [dataVisualAvailable, voteAvailable, linksAvailable] = await Promise.all([
|
||||
checkDataVisualPlugin(),
|
||||
checkVotePluginAvailable(),
|
||||
checkLinksPluginAvailable(),
|
||||
])
|
||||
}
|
||||
|
||||
/* ---------------- 数据加载 ---------------- */
|
||||
@@ -171,10 +158,9 @@ async function handleGetData() {
|
||||
}
|
||||
|
||||
/* ---------------- 交互 ---------------- */
|
||||
function handleOnNav(data: { path: string | null, isAdmin?: boolean }) {
|
||||
const { path, isAdmin } = data
|
||||
if (!path)
|
||||
return
|
||||
function handleNavGoTo(data : { path : string }) {
|
||||
const { path } = data
|
||||
if (!path) { return }
|
||||
|
||||
uni.navigateTo({ url: path })
|
||||
}
|
||||
@@ -194,67 +180,75 @@ onPullDownRefresh(() => {
|
||||
<template>
|
||||
<view class="box-border min-h-screen w-screen bg-page pb-2">
|
||||
<!-- 头部:博主信息(背景图 + 遮罩 + wave,内容区做状态栏适配) -->
|
||||
<view class="relative h-88 w-full bg-cover bg-no-repeat" :style="[calcProfileStyle]">
|
||||
<!-- 背景遮罩 -->
|
||||
<view class="absolute left-0 top-0 z-0 h-full w-full bg-black/30" style="backdrop-filter:blur(2rpx)"/>
|
||||
<view class="relative h-96 w-full bg-cover bg-no-repeat" :style="[calcProfileStyle]">
|
||||
<view class="relative z-6 h-full flex flex-col items-center justify-center">
|
||||
<image
|
||||
class="uh-global-card-glass h-20 w-20 rounded-full" :src="bloggerInfo.avatar"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<image class="uh-global-card-glass border-3 h-22 w-22 rounded-full" :src="bloggerInfo.avatar"
|
||||
mode="aspectFill" />
|
||||
<view class="mt-4 text-lg text-white font-bold text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">
|
||||
{{ bloggerInfo.nickname }}
|
||||
</view>
|
||||
<view
|
||||
class="desc mt-2 px-10 text-center text-2xs text-white/90 leading-relaxed text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]"
|
||||
>
|
||||
class="desc mt-2 px-10 text-center text-2xs text-white/90 leading-relaxed text-shadow-[0_2rpx_8rpx_rgba(0,0,0,0.4)]">
|
||||
{{ bloggerInfo.description || '这个博主很懒,竟然没写介绍~' }}
|
||||
</view>
|
||||
</view>
|
||||
<image
|
||||
v-if="calcWaveUrl" :src="calcWaveUrl" mode="scaleToFill"
|
||||
class="gif-wave absolute bottom-0 left-0 z-99 h-[100rpx] w-full" style="mix-blend-mode: screen;"
|
||||
/>
|
||||
|
||||
<!-- 遮罩 -->
|
||||
<view class="absolute left-0 top-0 z-0 h-full w-full bg-white/5" style="backdrop-filter:blur(4rpx)" />
|
||||
<image v-if="calcWaveUrl" :src="calcWaveUrl" mode="scaleToFill"
|
||||
class="gif-wave absolute bottom-0 left-0 z-90 h-18 w-full" style="mix-blend-mode: screen;" />
|
||||
<!-- 过渡 -->
|
||||
<view class="absolute bottom-0 left-0 z-100 h-18 w-full bg-gradient-to-b from-black/0 to-page" />
|
||||
</view>
|
||||
|
||||
<!-- 站点统计 -->
|
||||
<view class="uh-global-card-glass uh-shadow-xs relative z-100 mx-4 flex border rounded-2xl -mt-12">
|
||||
<view v-if="featureMode==='list'"
|
||||
class="uh-global-card-glass uh-shadow-xs relative z-100 mx-4 flex border rounded-2xl -mt-16">
|
||||
<view v-for="item in allStats" :key="item.key" class="flex-1 py-4 text-center">
|
||||
<wd-count-to
|
||||
:key="`${item.key}-${item.value}`" :start-val="0" :end-val="item.value" :duration="900"
|
||||
separator="" color="#111827" custom-class="text-lg font-bold"
|
||||
/>
|
||||
<wd-count-to :key="`${item.key}-${item.value}`" :start-val="0" :end-val="item.value" :duration="900"
|
||||
separator="" color="#111827" custom-class="text-lg font-bold" />
|
||||
<view class="mt-1 text-xs text-gray-500">
|
||||
{{ item.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 功能导航 -->
|
||||
<template v-for="group in calcNavGroups" :key="group.key">
|
||||
<view class="box-border px-4">
|
||||
<uh-section-title class="mb-3 mt-8">
|
||||
{{ group.title }}
|
||||
<!-- 功能导航:非分组模式 -->
|
||||
<template v-if="featureMode==='base'">
|
||||
<view v-if="commonFeatures.length!==0" class="relative z-100 -mt-20 box-border overflow-hidden p-4">
|
||||
<view class="box-border uh-global-card-glass uh-shadow-xs border p-3 grid grid-cols-4 gap-2 rounded-lb-2xl rounded-rb-2xl rounded-lt-3xl rounded-rt-3xl">
|
||||
<view v-for="(nav) in commonFeatures" :key="nav.key"
|
||||
class="uh-global-card-glass uh-shadow-xs rounded-2xl flex flex-col items-center justify-between p-2"
|
||||
@click="handleNavGoTo(nav)">
|
||||
<view
|
||||
class="uh-global-card-glass uh-shadow-xs h-8 w-8 flex items-center justify-center border rounded-xl"
|
||||
:style="{ backgroundColor: nav.bgColor }">
|
||||
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
|
||||
</view>
|
||||
<text class="mt-1 text-xs text-gray-900" :style="{ color: nav.color }">
|
||||
{{ nav.title }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="otherFeatures.length!==0">
|
||||
<view class="box-border px-4 mt-2 mb-3">
|
||||
<uh-section-title>
|
||||
其他功能
|
||||
</uh-section-title>
|
||||
</view>
|
||||
<view class="uh-global-card-glass mx-4 overflow-hidden rounded-2xl">
|
||||
<view
|
||||
v-for="(nav, index) in group.items" :key="nav.key"
|
||||
class="nav-item flex items-center justify-between px-4"
|
||||
:class="index < group.items.length - 1 ? 'border-b border-b-solid border-black/5' : ''"
|
||||
@click="handleOnNav(nav)"
|
||||
>
|
||||
<view class="uh-global-card-glass uh-shadow-xs mx-4 overflow-hidden rounded-2xl">
|
||||
<view v-for="(nav, index) in otherFeatures" :key="nav.key"
|
||||
class="flex items-center justify-between px-4"
|
||||
:class="index < otherFeatures.length - 1 ? 'border-b border-b-solid border-black/5' : ''"
|
||||
@click="handleNavGoTo(nav)">
|
||||
<view class="nav-left flex items-center gap-3 py-3">
|
||||
<view
|
||||
class="uh-global-card-glass uh-shadow-xs h-8 w-8 flex items-center justify-center border rounded-xl"
|
||||
:style="{ backgroundColor: nav.bgColor }"
|
||||
>
|
||||
:style="{ backgroundColor: nav.bgColor }">
|
||||
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
|
||||
</view>
|
||||
<text
|
||||
class="nav-title text-sm text-gray-900"
|
||||
:style="{ color: nav.color }"
|
||||
>
|
||||
<text class="nav-title text-sm text-gray-900" :style="{ color: nav.color }">
|
||||
{{ nav.title }}
|
||||
</text>
|
||||
</view>
|
||||
@@ -265,6 +259,39 @@ onPullDownRefresh(() => {
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- 功能导航:分组模式 -->
|
||||
<template v-else-if="featureMode==='list'">
|
||||
<template v-for="group in calcNavGroups" :key="group.key">
|
||||
<view class="box-border px-4">
|
||||
<uh-section-title class="mb-3 mt-8">
|
||||
{{ group.title }}
|
||||
</uh-section-title>
|
||||
</view>
|
||||
<view class="uh-global-card-glass mx-4 overflow-hidden rounded-2xl">
|
||||
<view v-for="(nav, index) in group.items" :key="nav.key"
|
||||
class="nav-item flex items-center justify-between px-4"
|
||||
:class="index < group.items.length - 1 ? 'border-b border-b-solid border-black/5' : ''"
|
||||
@click="handleNavGoTo(nav)">
|
||||
<view class="nav-left flex items-center gap-3 py-3">
|
||||
<view
|
||||
class="uh-global-card-glass uh-shadow-xs h-8 w-8 flex items-center justify-center border rounded-xl"
|
||||
:style="{ backgroundColor: nav.bgColor }">
|
||||
<wd-icon :class-prefix="nav.iconPrefix" :name="nav.icon" size="36rpx" />
|
||||
</view>
|
||||
<text class="nav-title text-sm text-gray-900" :style="{ color: nav.color }">
|
||||
{{ nav.title }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="nav-right flex items-center gap-2">
|
||||
<text class="nav-right-text text-xs text-gray-400">{{ nav.subTitle }}</text>
|
||||
<wd-icon name="arrow-right" size="24rpx" class="text-gray-400" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<uh-page-copyright />
|
||||
</view>
|
||||
|
||||
@@ -37,7 +37,7 @@ function isActive(index: number) {
|
||||
<template v-if="item.iconType === 'image'">
|
||||
<image :src="getImageByIndex(index, item)" mode="scaleToFill" class="shrink-0 h-6 w-6" />
|
||||
</template>
|
||||
<view class="mt-1px text-xs shrink-0">
|
||||
<view class="mt-1px text-10px shrink-0">
|
||||
{{ getI18nText(item.text) }}
|
||||
</view>
|
||||
<!-- 角标显示 -->
|
||||
|
||||
Reference in New Issue
Block a user