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>
|
||||
|
||||
@@ -243,14 +235,14 @@
|
||||
</view>
|
||||
|
||||
<block v-else>
|
||||
<view v-if="dataList.length === 0" class=" py-12">
|
||||
<view class=" flex flex-col items-center">
|
||||
<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) -->
|
||||
@@ -313,4 +306,4 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user