mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
refactor: 重构偏好设置与恋爱模块,对齐插件端字段结构
1. 重构布局偏好字段映射,移除嵌套layout结构,直接使用插件端同名字段 2. 新增恋爱模块token管理与密码解锁功能,支持恋爱故事/相册/清单的密码保护 3. 重构首页快捷导航,支持插件端直接配置导航项 4. 清理废弃配置字段,统一站点默认值与插件端结构 5. 修复文章卡片布局读取逻辑,适配新的偏好字段结构
This commit is contained in:
@@ -98,19 +98,26 @@
|
||||
|
||||
const isGrid = computed(() => props.variant === 'grid')
|
||||
|
||||
/** 各页面卡片样式字段名(与插件端 preferences 字段一致) */
|
||||
const CARD_TYPE_KEY: Record<'home' | 'articles' | 'archives', string> = {
|
||||
home: 'homeCardType',
|
||||
articles: 'articleCardType',
|
||||
archives: 'archivesCardType',
|
||||
}
|
||||
|
||||
/** 实际生效布局:显式 layout > 按页面读取全局 cardType(首页/文章列表/文章归档)> image_top;窄列场景左右布局回退上图下文 */
|
||||
const effectiveLayout = computed<CardLayout>(() => {
|
||||
const _layout = settingStore.settings.layout
|
||||
const settings = settingStore.settings
|
||||
const page = props.from === 'home' || props.from === 'articles' || props.from === 'archives'
|
||||
? props.from
|
||||
: null
|
||||
let raw = props.layout
|
||||
if (!raw) {
|
||||
raw = page
|
||||
? (_layout[page].cardType as CardLayout)
|
||||
? (settings[CARD_TYPE_KEY[page]] as CardLayout)
|
||||
: 'image_top'
|
||||
}
|
||||
const narrow = isGrid.value || (props.from === 'home' && _layout.home.listLayout === 'double')
|
||||
const narrow = isGrid.value || (props.from === 'home' && settings.homeListLayout === 'double')
|
||||
if (narrow && raw !== 'image_top') {
|
||||
return 'image_top'
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import { useAppConfigStore } from '@/store/appConfig'
|
||||
|
||||
const appConfigStore = useAppConfigStore()
|
||||
@@ -10,81 +10,119 @@
|
||||
const calcVotePluginEnabled = computed(() => !!haloConfigs.value.pluginConfig?.votePlugin?.enabled)
|
||||
const calcLinksPluginEnabled = computed(() => !!haloConfigs.value.pluginConfig?.linksPlugin?.enabled)
|
||||
|
||||
/** 快捷导航列表(由配置控制显隐) */
|
||||
/** 快捷导航项(字段命名与插件端 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
|
||||
}
|
||||
|
||||
/** 内置默认项(未配置时回退;字段命名与插件端一致,可作配置缺失字段的兜底) */
|
||||
const DEFAULT_NAV_LIST: QuickNavItem[] = [
|
||||
{
|
||||
key: 'archives',
|
||||
title: '文章归档',
|
||||
color: '#03A9F4',
|
||||
bgColor: 'rgba(3, 169, 244, 0.14)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-mask',
|
||||
path: '/pages-blog/archives/archives',
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
key: 'vote',
|
||||
title: '投票中心',
|
||||
color: '#00BCD4',
|
||||
bgColor: 'rgba(0, 188, 212, 0.14)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-confused',
|
||||
path: '/pages-blog/votes/votes',
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
key: 'disclaimers',
|
||||
title: '友情链接',
|
||||
color: '#009688',
|
||||
bgColor: 'rgba(0, 150, 136, 0.14)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-wink',
|
||||
path: '/pages-blog/friend-links/friend-links',
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
key: 'love',
|
||||
title: '恋爱日记',
|
||||
color: '#FF4C67',
|
||||
bgColor: 'rgba(255, 76, 103, 0.14)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-in-love',
|
||||
path: '/pages-blog/love/love',
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
key: 'contact-blogger',
|
||||
title: '联系博主',
|
||||
color: '#FF9800',
|
||||
bgColor: 'rgba(255, 152, 0, 0.14)',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-cool',
|
||||
path: '/pages-blog/contact/contact',
|
||||
visible: true,
|
||||
},
|
||||
]
|
||||
|
||||
/** 快捷导航列表:优先读插件端配置(零映射,visible 过滤);未配置/为空回退内置默认(保留原显隐推导) */
|
||||
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 ? '内容归档' : '文章归档',
|
||||
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: '投票中心',
|
||||
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,
|
||||
},
|
||||
{
|
||||
key: 'disclaimers',
|
||||
title: '友情链接',
|
||||
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,
|
||||
},
|
||||
{
|
||||
key: 'love',
|
||||
title: '恋爱日记',
|
||||
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,
|
||||
},
|
||||
{
|
||||
key: 'contact-blogger',
|
||||
title: '联系博主',
|
||||
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,
|
||||
},
|
||||
].filter(item => item.show)
|
||||
const loveEnabled = !!(haloConfigs.value.loveConfig as { loveEnabled ?: boolean })?.loveEnabled
|
||||
const configured = haloConfigs.value.pageConfig?.homeConfig?.quickNavigation
|
||||
let list: QuickNavItem[]
|
||||
if (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
|
||||
})
|
||||
}
|
||||
return list.filter(item => item.visible !== false)
|
||||
})
|
||||
|
||||
|
||||
function handleClickNav(item : { path : string }) {
|
||||
function handleClickNav(item : { path ?: string }) {
|
||||
if (!item.path)
|
||||
return
|
||||
uni.navigateTo({ url: item.path })
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-if="navList.length" class="box-border overflow-hidden rounded-xl p-3 px-4 mb-3">
|
||||
<view v-if="calcIsShowQuickNavigationEnabled && navList.length" class="box-border overflow-hidden rounded-xl p-3 px-4 mb-3">
|
||||
<uh-section-title class="mb-4">
|
||||
快捷导航
|
||||
</uh-section-title>
|
||||
@@ -94,7 +132,7 @@
|
||||
<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
|
||||
backgroundColor: item.bgColor
|
||||
}">
|
||||
<wd-icon :class-prefix="item.iconPrefix" :name="item.icon" size="64rpx"/>
|
||||
</view>
|
||||
@@ -104,4 +142,4 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
* 小程序友链信息弹窗
|
||||
* 展示本站小程序申请提交的信息,字段结构与小程序提交申请弹窗(uh-links-mini-apply)一致:
|
||||
* 小程序名称/太阳码/跳转地址/作者昵称/作者头像/作者网站/描述/申请说明/邮箱
|
||||
* 数据源:linksSubmitPlugin 配置(blogName→名称、blogLogo→太阳码、blogUrl→跳转地址、blogDesc→描述)
|
||||
* 数据源:插件端 getConfigs.pluginConfig.linkInfo(字段名与插件端一致,无映射;
|
||||
* displayName/miniProgramCode/link/description/applyRemark/authorName/avatar/website;
|
||||
* email 不在插件端维护,读不到时弹窗该栏自动隐藏)
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useAppConfigStore } from '@/store/appConfig'
|
||||
@@ -22,18 +24,18 @@ const emit = defineEmits<{
|
||||
const isShow = ref(false)
|
||||
const appConfigStore = useAppConfigStore()
|
||||
|
||||
/** 小程序申请信息(字段与 uh-links-mini-apply 表单一致,从 linksSubmitPlugin 配置读取) */
|
||||
/** 小程序申请信息(字段与 uh-links-mini-apply 表单一致,从插件端 linkInfo 配置直接读取,字段名无映射) */
|
||||
const miniInfo = computed(() => {
|
||||
const cfg = (appConfigStore.configs.pluginConfig?.linksSubmitPlugin || {}) as Record<string, unknown>
|
||||
const cfg = (appConfigStore.configs.pluginConfig?.linkInfo || {}) as Record<string, unknown>
|
||||
const str = (key: string, fallback = '') => String(cfg[key] || fallback || '')
|
||||
return {
|
||||
displayName: str('blogName'),
|
||||
miniProgramCode: str('blogLogo'),
|
||||
link: str('blogUrl'),
|
||||
displayName: str('displayName'),
|
||||
miniProgramCode: str('miniProgramCode'),
|
||||
link: str('link'),
|
||||
authorName: str('authorName'),
|
||||
avatar: str('avatar'),
|
||||
website: str('website'),
|
||||
description: str('blogDesc'),
|
||||
description: str('description'),
|
||||
applyRemark: str('applyRemark'),
|
||||
email: str('email'),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user