From eb19276a2d0a487e27709bdc2a9d100bb812784a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= Date: Thu, 10 Sep 2026 00:44:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B8=85=E7=90=86=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E6=B3=A8=E9=87=8A=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=BB=84=E4=BB=B6=E6=A0=B7=E5=BC=8F=E4=B8=8E=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 移除appSettings.ts和appConfig.ts中的旧注释文档 2. 优化首页分类、文章页的箭头按钮样式与尺寸 3. 隐藏home页的多余"更多"按钮并统一右侧按钮样式 4. 重构快捷导航组件的逻辑,简化默认列表渲染 5. 优化文章卡片的布局样式、结构和代码组织 --- .../uh-article-card/uh-article-card.vue | 94 ++++++++++--------- .../uh-home-category/uh-home-category.vue | 4 +- .../uh-home-quick-nav/uh-home-quick-nav.vue | 56 ++++------- src/config/appConfig.ts | 7 -- src/config/appSettings.ts | 7 -- src/pages/tabbar/home/home.vue | 8 +- 6 files changed, 75 insertions(+), 101 deletions(-) diff --git a/src/components/uh-article-card/uh-article-card.vue b/src/components/uh-article-card/uh-article-card.vue index 558c90d..fe15ec0 100644 --- a/src/components/uh-article-card/uh-article-card.vue +++ b/src/components/uh-article-card/uh-article-card.vue @@ -8,26 +8,42 @@ type CardLayout = 'image_top' | 'image_right' | 'image_bottom' | 'image_left' interface CardLayoutClasses { - container: string - cover: string - contentWrapper: string - footer: string - authorGroup: string - avatar: string - nickname: string - infoCol: string - time: string - tagCategory: string - visits: string - pinned: string + container : string + cover : string + contentWrapper : string + footer : string + authorGroup : string + avatar : string + nickname : string + infoCol : string + time : string + tagCategory : string + visits : string + pinned : string } + const props = withDefaults(defineProps<{ + from ?: 'home' | 'articles' | 'archives' | '' + auditMode ?: boolean + article : IPost + variant ?: 'list' | 'grid' + layout ?: CardLayout + }>(), { + auditMode: false, + from: '', + variant: 'list', + }) + + const settingStore = useSettingStore() + + const isGrid = computed(() => props.variant === 'grid') + /** 单一事实源:每种布局的完整形态,模板不再有任何 order / 条件分支 */ - const CARD_LAYOUTS: Record = { + const CARD_LAYOUTS = computed(()=> ({ image_top: { - container: 'flex flex-col gap-y-2', - cover: '', - contentWrapper: 'w-full', + container: `flex flex-col gap-y-2 ${isGrid.value ? '!p-0' : ''}`, + cover: `${isGrid.value ? 'rounded-lb-0 rounded-rb-0' : ''}`, + contentWrapper: `box-border w-full ${isGrid.value ? 'p-2 pt-0' : ''}`, footer: 'flex items-center', authorGroup: 'flex-1 items-center justify-start gap-x-1', avatar: '', @@ -36,7 +52,7 @@ time: 'flex-1 text-center', tagCategory: '', visits: 'flex-1 justify-end', - pinned: 'right-4 top-4', + pinned: `${isGrid.value ? 'right-2 top-2' : 'right-4 top-4'}`, }, image_bottom: { container: 'flex flex-col gap-y-2', @@ -80,26 +96,10 @@ visits: '', pinned: 'right-3 top-3', }, - } - - const props = withDefaults(defineProps<{ - from ?: 'home' | 'articles' | 'archives' | '' - auditMode ?: boolean - article : IPost - variant ?: 'list' | 'grid' - layout ?: CardLayout - }>(), { - auditMode: false, - from: '', - variant: 'list', - }) - - const settingStore = useSettingStore() - - const isGrid = computed(() => props.variant === 'grid') + }) as Record) /** 各页面卡片样式字段名(与插件端 preferences 字段一致) */ - const CARD_TYPE_KEY: Record<'home' | 'articles' | 'archives', string> = { + const CARD_TYPE_KEY : Record<'home' | 'articles' | 'archives', string> = { home: 'homeCardType', articles: 'articleCardType', archives: 'archivesCardType', @@ -124,7 +124,7 @@ return raw }) - const cardLayout = computed(() => CARD_LAYOUTS[effectiveLayout.value] ?? CARD_LAYOUTS.image_top) + const cardLayout = computed(() => CARD_LAYOUTS.value[effectiveLayout.value] ?? CARD_LAYOUTS.value.image_top) /** 社交卡片形态(封面在下):左上用户信息(头像 + 昵称/日期垂直)、右上浏览数 */ const isSocialCard = computed(() => effectiveLayout.value === 'image_bottom') @@ -146,7 +146,7 @@ url: `/pages-blog/article-detail/article-detail?name=${props.article.metadata.name}`, animationType: 'slide-in-right', }) - } + } \ No newline at end of file diff --git a/src/components/uh-home-category/uh-home-category.vue b/src/components/uh-home-category/uh-home-category.vue index fb3b6f0..4826331 100644 --- a/src/components/uh-home-category/uh-home-category.vue +++ b/src/components/uh-home-category/uh-home-category.vue @@ -78,9 +78,9 @@ 精选分类 diff --git a/src/components/uh-home-quick-nav/uh-home-quick-nav.vue b/src/components/uh-home-quick-nav/uh-home-quick-nav.vue index abb33bd..bd32af7 100644 --- a/src/components/uh-home-quick-nav/uh-home-quick-nav.vue +++ b/src/components/uh-home-quick-nav/uh-home-quick-nav.vue @@ -12,18 +12,20 @@ /** 快捷导航项(字段命名与插件端 quickNavigation 一致:key/title/color/bgColor/iconPrefix/icon/path/visible,无 borderColor) */ interface QuickNavItem { - key: string - title?: string - color?: string - bgColor?: string - iconPrefix?: string - icon?: string - path?: string - visible?: boolean + key : string + title ?: string + color ?: string + bgColor ?: string + iconPrefix ?: string + icon ?: string + path ?: string + visible ?: boolean } + // 是否使用本地的快捷导航数据(本地的可以任意修改图标、路径,插件端的无法修改图标) + const useLocalNav = false /** 内置默认项(未配置时回退;字段命名与插件端一致,可作配置缺失字段的兜底) */ - const DEFAULT_NAV_LIST: QuickNavItem[] = [ + const DEFAULT_NAV_LIST : QuickNavItem[] = [ { key: 'archives', title: '文章归档', @@ -78,37 +80,16 @@ /** 快捷导航列表:优先读插件端配置(零映射,visible 过滤);未配置/为空回退内置默认(保留原显隐推导) */ const navList = computed(() => { - const socialEnabled = !!(haloConfigs.value.authorConfig?.social as { enabled ?: boolean } | undefined)?.enabled - const loveEnabled = !!(haloConfigs.value.loveConfig as { loveEnabled ?: boolean })?.loveEnabled const configured = haloConfigs.value.pageConfig?.homeConfig?.quickNavigation - let list: QuickNavItem[] - if (configured && configured.length) { + let list : QuickNavItem[] + if (!useLocalNav && configured && configured.length) { // 配置模式:以配置项为准,缺失字段(icon/iconPrefix/color/path 等)按 key 从默认项兜底 list = configured.map(item => { const fallback = DEFAULT_NAV_LIST.find(d => d.key === item.key) || DEFAULT_NAV_LIST[0] return { ...fallback, ...item } }) - } - else { - // 默认模式(老部署无配置):回退内置默认项,保留原显隐推导 - list = DEFAULT_NAV_LIST.map(item => { - if (item.key === 'archives') { - return { ...item, title: calcAuditModeEnabled.value ? '内容归档' : item.title } - } - if (item.key === 'contact-blogger') { - return { ...item, visible: socialEnabled } - } - if (item.key === 'love') { - return { ...item, visible: loveEnabled } - } - if (item.key === 'vote') { - return { ...item, visible: calcVotePluginEnabled.value } - } - if (item.key === 'disclaimers') { - return { ...item, visible: calcLinksPluginEnabled.value } - } - return item - }) + } else { + list = DEFAULT_NAV_LIST; } return list.filter(item => item.visible !== false) }) @@ -122,7 +103,8 @@ + \ No newline at end of file diff --git a/src/config/appConfig.ts b/src/config/appConfig.ts index 0a33c1b..a18e56f 100644 --- a/src/config/appConfig.ts +++ b/src/config/appConfig.ts @@ -1,10 +1,3 @@ -/** - * 应用配置默认值(源自旧项目 config/index.js 的 DefaultAppConfigs) - * 与 src/api/uni-halo.ts 的 getAppConfigs(plugin-uni-halo/getConfigs)配合,deepMerge 使用 - * 页面/组件依赖其字段结构(pluginConfig.toolsPlugin.Authorization 等),改动需谨慎 - * 2026-09-08 清理:与插件端 getConfigs 结构统一,移除已下线/无消费的默认字段 - * (tokenConfig/pageTitle/bannerConfig/categoryConfig.type 等) - */ import type { IAppConfig } from '@/api/types/uni-halo' export const DefaultAppConfigs: IAppConfig = { diff --git a/src/config/appSettings.ts b/src/config/appSettings.ts index 69e604a..694c103 100644 --- a/src/config/appSettings.ts +++ b/src/config/appSettings.ts @@ -1,10 +1,3 @@ -/** - * 应用设置默认值与类型(源自旧项目 utils/app.js 的 _DefaultAppSettings) - * 布局偏好字段命名与插件端 getConfigs.preferences 一致(2026-09-08 起去映射,以插件端字段为准) - * 2026-09-08 清理:banner/ad/gallery/links/about/article/contact 等无消费字段已移除, - * 仅保留偏好相关字段(与插件端 preferences 结构对齐) - */ - export interface IAppSettings { /** 评论头像是否圆形(插件端字段 avatarRadius) */ avatarRadius: boolean diff --git a/src/pages/tabbar/home/home.vue b/src/pages/tabbar/home/home.vue index 006b7da..a678758 100644 --- a/src/pages/tabbar/home/home.vue +++ b/src/pages/tabbar/home/home.vue @@ -229,14 +229,14 @@ @click="handleRecommendModeChange(tab.value as 'default' | 'pinned' | 'latest' | 'oldest')"> {{ tab.label }} - + 更多 - - +