mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
refactor: 整体项目样式与组件优化升级
主要变更: 1. 新增uhemoji2图标字体库并全局引入 2. 重构导航组件与页面布局,统一使用自定义导航栏 3. 替换旧图标为emoji图标,统一视觉风格 4. 清理冗余调试代码与注释 5. 优化快捷导航、关于页等页面样式与交互 6. 修复滚动到顶部组件黑名单配置
This commit is contained in:
@@ -1,100 +1,79 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { getNotices } from '@/api/uni-halo'
|
||||
import type { INoticeListVo } from '@/api/types/uni-halo'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { getNotices } from '@/api/uni-halo'
|
||||
import type { INoticeListVo } from '@/api/types/uni-halo'
|
||||
|
||||
/** 轮播展示条数上限(垂直循环) */
|
||||
const MAX_SHOW = 6
|
||||
/** 轮播展示条数上限(垂直循环) */
|
||||
const MAX_SHOW = 6
|
||||
|
||||
const list = ref<INoticeListVo[]>([])
|
||||
const showList = computed(() => list.value.slice(0, MAX_SHOW))
|
||||
const list = ref<INoticeListVo[]>([])
|
||||
const showList = computed(() => list.value.slice(0, MAX_SHOW))
|
||||
|
||||
async function fetchNotices() {
|
||||
try {
|
||||
const res = await getNotices({ page: 1, size: MAX_SHOW })
|
||||
list.value = res.data?.items || []
|
||||
}
|
||||
catch (err) {
|
||||
console.error('首页公告获取失败', err)
|
||||
list.value = []
|
||||
}
|
||||
}
|
||||
async function fetchNotices() {
|
||||
try {
|
||||
const res = await getNotices({ page: 1, size: MAX_SHOW })
|
||||
list.value = res.data?.items || []
|
||||
}
|
||||
catch (err) {
|
||||
console.error('首页公告获取失败', err)
|
||||
list.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 点击单条公告标题 → 详情页 */
|
||||
function handleTap(item: INoticeListVo) {
|
||||
if (!item.name)
|
||||
return
|
||||
uni.navigateTo({ url: `/pages-blog/notice/detail?name=${item.name}` })
|
||||
}
|
||||
/** 点击单条公告标题 → 详情页 */
|
||||
function handleTap(item : INoticeListVo) {
|
||||
if (!item.name) { return }
|
||||
uni.navigateTo({ url: `/pages-blog/notice/detail?name=${item.name}` })
|
||||
}
|
||||
|
||||
/** 点击「公告/更多」→ 公告列表页 */
|
||||
function handleGoList() {
|
||||
uni.navigateTo({ url: '/pages-blog/notice/notice' })
|
||||
}
|
||||
/** 点击「公告/更多」→ 公告列表页 */
|
||||
function handleGoList() {
|
||||
uni.navigateTo({ url: '/pages-blog/notice/notice' })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchNotices()
|
||||
})
|
||||
onMounted(() => {
|
||||
fetchNotices()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view
|
||||
v-if="showList.length > 0"
|
||||
class="uh-global-card-glass box-border mx-3 mt-3 mb-2 flex items-center rounded-xl px-3"
|
||||
>
|
||||
<!-- 左侧公告入口 -->
|
||||
<view class="flex shrink-0 items-center gap-1 py-2 pr-3" @click="handleGoList">
|
||||
<text class="text-sm">
|
||||
📢
|
||||
</text>
|
||||
<text class="text-xs font-bold text-red-400">
|
||||
公告
|
||||
</text>
|
||||
</view>
|
||||
<view v-if="showList.length > 0"
|
||||
class="uh-global-card-glass box-border mx-3 mt-3 mb-2 flex items-center rounded-xl px-3">
|
||||
<!-- 左侧公告入口 -->
|
||||
<view class="flex shrink-0 items-center gap-2 py-2 pr-3" @click="handleGoList">
|
||||
<wd-icon class-prefix="uhemoji2-icon" name="-happy-" size="36rpx" />
|
||||
<text class="text-sm font-bold text-red-400">
|
||||
公告
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<!-- 标题轮播(仅一条时静态展示) -->
|
||||
<view class="h-[60rpx] min-w-0 flex-1 overflow-hidden">
|
||||
<swiper
|
||||
v-if="showList.length > 1"
|
||||
class="h-full w-full"
|
||||
vertical
|
||||
circular
|
||||
autoplay
|
||||
:interval="3500"
|
||||
:duration="400"
|
||||
>
|
||||
<swiper-item
|
||||
v-for="(item, index) in showList"
|
||||
:key="item.name || index"
|
||||
class="h-full w-full"
|
||||
>
|
||||
<view
|
||||
class="flex h-full w-full items-center truncate text-xs text-gray-500"
|
||||
@click="handleTap(item)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view
|
||||
v-else
|
||||
class="flex h-full w-full items-center truncate text-[24rpx] text-[#555]"
|
||||
@click="handleTap(showList[0])"
|
||||
>
|
||||
{{ showList[0]?.title }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 标题轮播(仅一条时静态展示) -->
|
||||
<view class="h-[60rpx] min-w-0 flex-1 overflow-hidden">
|
||||
<swiper v-if="showList.length > 1" class="h-full w-full" vertical circular autoplay :interval="3500"
|
||||
:duration="400">
|
||||
<swiper-item v-for="(item, index) in showList" :key="item.name || index" class="h-full w-full">
|
||||
<view class="flex h-full w-full items-center truncate text-xs text-gray-500"
|
||||
@click="handleTap(item)">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view v-else class="flex h-full w-full items-center truncate text-[24rpx] text-[#555]"
|
||||
@click="handleTap(showList[0])">
|
||||
{{ showList[0]?.title }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 右侧更多入口 -->
|
||||
<view class="flex shrink-0 items-center gap-0.5 py-2 pl-2" @click="handleGoList">
|
||||
<text class="text-[22rpx] text-[#bbb]">
|
||||
更多
|
||||
</text>
|
||||
<wd-icon name="arrow-right" size="12px" color="#bbb" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 右侧更多入口 -->
|
||||
<view class="flex shrink-0 items-center gap-0.5 py-2 pl-2" @click="handleGoList">
|
||||
<text class="text-[22rpx] text-[#bbb]">
|
||||
更多
|
||||
</text>
|
||||
<wd-icon name="arrow-right" size="12px" color="#bbb" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 布局由 UnoCSS 原子类实现 */
|
||||
</style>
|
||||
/* 布局由 UnoCSS 原子类实现 */
|
||||
</style>
|
||||
@@ -14,20 +14,27 @@
|
||||
const navList = computed(() => {
|
||||
const loveEnabled = !!(haloConfigs.value.loveConfig as { loveEnabled ?: boolean })?.loveEnabled
|
||||
const socialEnabled = !!(haloConfigs.value.authorConfig?.social as { enabled ?: boolean } | undefined)?.enabled
|
||||
// <wd-icon class-prefix="uhemoji-icon" name="-smile-" size="32rpx" />
|
||||
return [
|
||||
{
|
||||
key: 'archives',
|
||||
title: calcAuditModeEnabled.value ? '内容归档' : '文章归档',
|
||||
bgColor: 'rgba(3, 169, 244, 0.95)',
|
||||
icon: 'news',
|
||||
color: '#03A9F4',
|
||||
bgGlass: 'rgba(3, 169, 244, 0.14)',
|
||||
borderColor: 'rgba(3, 169, 244, 0.35)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-mask',
|
||||
path: '/pages-blog/archives/archives',
|
||||
show: true,
|
||||
},
|
||||
{
|
||||
key: 'vote',
|
||||
title: '投票中心',
|
||||
bgColor: 'rgba(0, 188, 212, 0.95)',
|
||||
icon: 'box',
|
||||
color: '#00BCD4',
|
||||
bgGlass: 'rgba(0, 188, 212, 0.14)',
|
||||
borderColor: 'rgba(0, 188, 212, 0.35)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-confused',
|
||||
path: '/pages-blog/votes/votes',
|
||||
// show: !calcAuditModeEnabled.value && calcVotePluginEnabled.value,
|
||||
show: true,
|
||||
@@ -35,8 +42,11 @@
|
||||
{
|
||||
key: 'disclaimers',
|
||||
title: '友情链接',
|
||||
bgColor: 'rgba(0, 150, 136, 0.95)',
|
||||
icon: 'link',
|
||||
color: '#009688',
|
||||
bgGlass: 'rgba(0, 150, 136, 0.14)',
|
||||
borderColor: 'rgba(0, 150, 136, 0.35)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-wink',
|
||||
path: '/pages-blog/friend-links/friend-links',
|
||||
// show: calcLinksPluginEnabled.value,
|
||||
show: true,
|
||||
@@ -44,8 +54,11 @@
|
||||
{
|
||||
key: 'love',
|
||||
title: '恋爱日记',
|
||||
bgColor: 'rgba(255, 76, 103, 0.95)',
|
||||
icon: 'heart',
|
||||
color: '#FF4C67',
|
||||
bgGlass: 'rgba(255, 76, 103, 0.14)',
|
||||
borderColor: 'rgba(255, 76, 103, 0.075)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-in-love',
|
||||
path: '/pages-blog/love/love',
|
||||
// show: loveEnabled,
|
||||
show: true,
|
||||
@@ -53,8 +66,11 @@
|
||||
{
|
||||
key: 'contact-blogger',
|
||||
title: '联系博主',
|
||||
bgColor: 'rgba(255, 152, 0, 0.95)',
|
||||
icon: 'message',
|
||||
color: '#FF9800',
|
||||
bgGlass: 'rgba(255, 152, 0, 0.14)',
|
||||
borderColor: 'rgba(255, 152, 0, 0.35)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-cool',
|
||||
path: '/pages-blog/contact/contact',
|
||||
show: socialEnabled,
|
||||
},
|
||||
@@ -68,21 +84,37 @@
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-if="navList.length" class="overflow-hidden rounded-xl p-3 px-4 mb-3">
|
||||
<view v-if="navList.length" class="box-border overflow-hidden rounded-xl p-3 px-4 mb-3">
|
||||
<uh-section-title class="mb-4">
|
||||
快捷导航
|
||||
</uh-section-title>
|
||||
<view class="grid grid-cols-5 gap-4">
|
||||
<view v-for="item in navList" :key="item.key" class="flex flex-col items-center gap-2"
|
||||
@click="handleClickNav(item)">
|
||||
<view class="uh-global-card-glass border h-12 w-12 flex items-center justify-center rounded-2xl"
|
||||
:style="{ backgroundColor: item.bgColor }">
|
||||
<wd-icon :name="item.icon" size="24px" color="#fff" />
|
||||
<view
|
||||
class="uh-global-card-glass uh-shadow-xs h-13 w-13 flex items-center justify-center rounded-2xl border transition-transform active:scale-90"
|
||||
:style="{
|
||||
backgroundColor: item.bgGlass
|
||||
}">
|
||||
<wd-icon :class-prefix="item.iconPrefix" :name="item.icon" size="64rpx" :color="item.color" />
|
||||
</view>
|
||||
<view class="text-xs text-gray-900 font-bold">
|
||||
<view class="text-xs text-gray-900">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 彩色玻璃图标:低透明度同色底 + 同色描边 + 柔和同色投影,图标用实体色保证通透感 */
|
||||
.quick-nav-icon {
|
||||
backdrop-filter: blur(16rpx) saturate(160%);
|
||||
-webkit-backdrop-filter: blur(16rpx) saturate(160%);
|
||||
|
||||
/* 低端安卓 WebView 不支持 backdrop-filter 的兜底:提高底色不透明度保证可读性 */
|
||||
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
||||
background-color: rgb(255 255 255 / 60%) !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -6,12 +6,15 @@
|
||||
useBack : boolean;
|
||||
useTitle : boolean;
|
||||
defaultTitle ?: string;
|
||||
titleColor ?: string;
|
||||
scrollTitle ?: string;
|
||||
needPlaceholder ?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
useBack: true,
|
||||
useTitle: true,
|
||||
needPlaceholder: true,
|
||||
})
|
||||
|
||||
const slots = useSlots()
|
||||
@@ -31,6 +34,10 @@
|
||||
|
||||
const customCalss = computed(() => {
|
||||
const _class = []
|
||||
if (props.titleColor) {
|
||||
_class.push(props.titleColor)
|
||||
return
|
||||
}
|
||||
if (scrollThreshold.value) {
|
||||
_class.push('text-white')
|
||||
}
|
||||
@@ -49,9 +56,9 @@
|
||||
}
|
||||
return props.scrollTitle;
|
||||
})
|
||||
|
||||
|
||||
// todo:注意:如果是从分享进来的,我们需要处理为返回 home页面
|
||||
function handleBack(){
|
||||
function handleBack() {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}
|
||||
|
||||
@@ -61,25 +68,30 @@
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="box-border pt-safe w-full fixed left-0 top-0 z-50" :class="customCalss" :style="[customStyle]">
|
||||
<view class="w-full h-[46px] flex items-center gap-x-4 box-border px-3 backdrop-blur-[2rpx]">
|
||||
<!-- 左边 -->
|
||||
<view class="shrink-0" @click="handleBack()">
|
||||
<view
|
||||
class="uh-global-card-glass h-7 px-3 rounded-full border flex items-center gap-x-2 text-gray-900 text-sm">
|
||||
<wd-icon name="arrow-left" size="32rpx"></wd-icon>
|
||||
<view class="w-[1px] h-4 bg-white/60" />
|
||||
<text class="text-xs font-bold">返回</text>
|
||||
<view class="w-full box-border">
|
||||
<view class="box-border pt-safe w-full fixed left-0 top-0 z-50" :class="customCalss" :style="[customStyle]">
|
||||
<view class="w-full h-[46px] flex items-center gap-x-4 box-border px-3 backdrop-blur-[2rpx]">
|
||||
<!-- 左边 -->
|
||||
<view class="shrink-0" @click="handleBack()">
|
||||
<view
|
||||
class="uh-global-card-glass h-7 px-3 rounded-full border flex items-center gap-x-2 text-gray-900 text-sm">
|
||||
<wd-icon name="arrow-left" size="32rpx"></wd-icon>
|
||||
<view class="w-[1px] h-4 bg-white/60" />
|
||||
<text class="text-xs font-bold">返回</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 中间 -->
|
||||
<view class="flex-1 truncate text-center font-bold transition-colors duration-300">
|
||||
<slot> {{visibleTitle}} </slot>
|
||||
</view>
|
||||
<!-- 右边 -->
|
||||
<view class="shrink-0 min-w-18">
|
||||
<slot name="right"></slot>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 中间 -->
|
||||
<view class="flex-1 truncate text-center font-bold transition-colors duration-300">
|
||||
<slot> {{visibleTitle}} </slot>
|
||||
</view>
|
||||
<!-- 右边 -->
|
||||
<view class="shrink-0 min-w-18">
|
||||
<slot name="right"></slot>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="props.needPlaceholder" class="box-border w-full pt-safe">
|
||||
<view class="w-full h-[46px]"></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -81,9 +81,7 @@
|
||||
<!-- 头部:标题 + 关闭 -->
|
||||
<view class="flex items-center justify-between">
|
||||
<view class="flex items-center gap-2">
|
||||
<text class="text-sm">
|
||||
📢
|
||||
</text>
|
||||
<wd-icon class-prefix="uhemoji2-icon" name="-happy-" size="36rpx" />
|
||||
<text class="text-md font-bold text-gray-900">
|
||||
最新公告
|
||||
</text>
|
||||
@@ -101,7 +99,8 @@
|
||||
|
||||
<!-- 内容 -->
|
||||
<view class="mt-4">
|
||||
<image v-if="notice.cover" :src="checkImageUrl(notice.cover)" class="w-full h-34 rounded-lg mb-2"></image>
|
||||
<image v-if="notice.cover" :src="checkImageUrl(notice.cover)" class="w-full h-34 rounded-lg mb-2">
|
||||
</image>
|
||||
<view class="text-md font-bold leading-snug text-gray-900">
|
||||
{{ notice.title }}
|
||||
</view>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 插件不可用提示(源自旧项目 components/plugin-unavailable,新建复刻)
|
||||
* 当依赖的 Halo 插件未安装/未启用时展示:插件 logo、名称、错误标签、描述、插件地址、复制/反馈按钮
|
||||
*/
|
||||
import { computed } from 'vue'
|
||||
import { NeedPlugins } from '@/hooks/usePluginAvailable'
|
||||
|
||||
@@ -45,18 +41,7 @@
|
||||
...defaultStyle,
|
||||
...props.customStyle,
|
||||
}))
|
||||
|
||||
function copy() {
|
||||
if (!pluginInfo.value.url)
|
||||
return
|
||||
uni.setClipboardData({
|
||||
data: pluginInfo.value.url,
|
||||
showToast: false,
|
||||
success: () => {
|
||||
uni.showToast({ icon: 'none', title: '插件地址已复制' })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
|
||||
// 获取当前页面,并且设置黑名单模式,因为有的页面可能不需要滚动到顶部
|
||||
const balckList = ['pages/maintenance/maintenance']
|
||||
const balckList = ['pages/maintenance/maintenance','pages-blog/setting/setting']
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const visible = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user