mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
refactor: 优化样式配置与代码逻辑,修复部分细节问题
1. 移除markdown代码块的默认文字颜色变量 2. 简化快捷导航背景色为hex8格式统一管理 3. 重构联系页社交链接逻辑与空状态展示 4. 优化about页的颜色转换工具函数与默认配色 5. 调整App.vue初始化调用与移除冗余代码
This commit is contained in:
+6
-7
@@ -1,5 +1,4 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||
import { getCurrentInstance, onMounted, onUnmounted } from 'vue'
|
||||
import { navigateToInterceptor } from '@/router/interceptor'
|
||||
@@ -14,8 +13,8 @@
|
||||
|
||||
onLaunch((options) => {
|
||||
// 初始化获取配置
|
||||
useAppConfigStore()
|
||||
|
||||
useAppConfigStore().refreshStatic()
|
||||
|
||||
console.log('App.vue onLaunch', options)
|
||||
})
|
||||
onShow((options) => {
|
||||
@@ -50,8 +49,8 @@
|
||||
window.removeEventListener('pageshow', syncTabbarWhenPageVisible)
|
||||
})
|
||||
// #endif
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
</style>
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
// 是否使用本地的快捷导航数据(本地的可以任意修改图标、路径,插件端的无法修改图标)
|
||||
const useLocalNav = false
|
||||
/** 内置默认项(未配置时回退;字段命名与插件端一致,可作配置缺失字段的兜底) */
|
||||
/** 内置默认项(未配置时回退;字段命名与插件端一致,可作配置缺失字段的兜底;颜色统一 hex8) */
|
||||
const DEFAULT_NAV_LIST : QuickNavItem[] = [
|
||||
{
|
||||
key: 'archives',
|
||||
title: '文章归档',
|
||||
subTitle: '全部文章',
|
||||
color: '#03A9F4',
|
||||
bgColor: 'rgba(3, 169, 244, 0.14)',
|
||||
bgColor: '#03A9F424',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-mask',
|
||||
path: '/pages-blog/archives/archives',
|
||||
@@ -41,7 +41,7 @@
|
||||
key: 'vote',
|
||||
title: '投票中心',
|
||||
color: '#00BCD4',
|
||||
bgColor: 'rgba(0, 188, 212, 0.14)',
|
||||
bgColor: '#00BCD424',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-confused',
|
||||
path: '/pages-blog/votes/votes',
|
||||
@@ -51,7 +51,7 @@
|
||||
key: 'disclaimers',
|
||||
title: '友情链接',
|
||||
color: '#009688',
|
||||
bgColor: 'rgba(0, 150, 136, 0.14)',
|
||||
bgColor: '#00968824',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-wink',
|
||||
path: '/pages-blog/friend-links/friend-links',
|
||||
@@ -61,7 +61,7 @@
|
||||
key: 'love',
|
||||
title: '恋爱日记',
|
||||
color: '#FF4C67',
|
||||
bgColor: 'rgba(255, 76, 103, 0.14)',
|
||||
bgColor: '#FF4C6724',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-in-love',
|
||||
path: '/pages-blog/love/love',
|
||||
@@ -71,7 +71,7 @@
|
||||
key: 'contact-blogger',
|
||||
title: '联系博主',
|
||||
color: '#FF9800',
|
||||
bgColor: 'rgba(255, 152, 0, 0.14)',
|
||||
bgColor: '#FF980024',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-cool',
|
||||
path: '/pages-blog/contact/contact',
|
||||
|
||||
@@ -11,7 +11,6 @@ export const markdownConfig = {
|
||||
margin-bottom: 18px;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
color: var(--routine);
|
||||
background: #f2f6fc;
|
||||
border: 1px solid #dcdcdc;
|
||||
border-radius: 4px;
|
||||
|
||||
@@ -14,10 +14,8 @@
|
||||
})
|
||||
|
||||
interface ISoical {
|
||||
key ?: string
|
||||
name : string
|
||||
content : string
|
||||
icon ?: string,
|
||||
color : string,
|
||||
bgColor : string,
|
||||
priority ?: number,
|
||||
@@ -45,11 +43,11 @@
|
||||
return []
|
||||
}
|
||||
return [...configured]
|
||||
.filter(item => item.visible !== false)
|
||||
.filter(item => item.visible && item.content.trim())
|
||||
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
|
||||
})
|
||||
|
||||
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && !!item.content))
|
||||
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && item.content.trim()))
|
||||
|
||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||
watchEffect(() => {
|
||||
@@ -67,7 +65,6 @@
|
||||
})
|
||||
}
|
||||
|
||||
/* ---------------- 实时时间(收信日期,formatTime 工具每秒刷新) ---------------- */
|
||||
const nowText = ref('')
|
||||
let clock : ReturnType<typeof setInterval> | null = null
|
||||
function refreshNowText() {
|
||||
@@ -121,11 +118,16 @@
|
||||
<view class="text-md text-gray-900">
|
||||
展信安:
|
||||
</view>
|
||||
<mp-html v-if="bloggerInfo.intro" lazy-load :domain="markdownConfig.domain ?? ''"
|
||||
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
|
||||
:show-language-name="true" copy-by-long-press />
|
||||
<view v-if="bloggerInfo.intro" class="text-gray-900 text-sm">
|
||||
<mp-html lazy-load :domain="markdownConfig.domain ?? ''"
|
||||
:loading-img="markdownConfig.loadingGif" scroll-table selectable
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="bloggerInfo.intro" :markdown="true" :show-line-number="true"
|
||||
:show-language-name="true" copy-by-long-press />
|
||||
</view>
|
||||
<view v-else class="text-gray-600 text-sm py-4">
|
||||
祝你早安,午安,晚安。每天都有好心情,生活愉快!
|
||||
</view>
|
||||
<view class="mt-2 w-full flex items-end flex-col gap-y-3">
|
||||
<text class="text-md font-semibold text-gray-900">{{ bloggerInfo.nickname }}</text>
|
||||
<text class="text-xs text-black/60">{{ nowText }}</text>
|
||||
@@ -133,16 +135,21 @@
|
||||
</view>
|
||||
|
||||
<view class="box-border pt-4 w-full flex flex-col gap-y-2 border-t border-t-dashed border-gray-200">
|
||||
<view class="mb-2 text-md text-gray-900">
|
||||
若有意,可依此觅:
|
||||
</view>
|
||||
<view v-for="item in socialList" :key="item.name" class="flex items-center gap-3"
|
||||
@click="handleOnClick(item)">
|
||||
<view
|
||||
class="uh-global-card-glass uh-shadow-xs border h-10 w-10 flex shrink-0 items-center justify-center rounded-xl"
|
||||
class="uh-global-card-glass uh-shadow-xs border h-11 w-11 flex shrink-0 items-center justify-center rounded-xl"
|
||||
:style="{ backgroundColor: item.bgColor ,color:item.color }">
|
||||
<text class="text-sm text-gray-500 font-bold"> {{ item.icon }} </text>
|
||||
<text class="text-sm font-bold" :style="{ color:item.color }">
|
||||
{{ item.name ? item.name.charAt(0) : '' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="min-w-0 flex flex-1 flex-col">
|
||||
<text class="text-xs text-gray-500">{{ item.name }}</text>
|
||||
<view class="mt-1 break-all text-sm text-gray-900 leading-snug">
|
||||
<text class="text-xs text-gray-500" >{{ item.name }}</text>
|
||||
<view class="mt-1 break-all text-xs text-gray-900">
|
||||
{{ item.content }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -157,14 +157,14 @@
|
||||
})
|
||||
|
||||
/* ---------------- 功能导航 ---------------- */
|
||||
/** 图标块浅色背景:品牌深色 rgba 降透明度 → 轻量底色 */
|
||||
function toLightBg(rgba : string) {
|
||||
return rgba.replace('0.95)', '0.15)')
|
||||
/** 图标块浅色背景:品牌深色 hex8 降透明度 → 轻量底色(#rrggbbaa 后两位替换为 26,≈0.15 透明度) */
|
||||
function toLightBg(hex8 : string) {
|
||||
return (hex8 || '').replace(/(#[0-9a-fA-F]{6})[0-9a-fA-F]{2}$/, (_m, base) => `${base}26`)
|
||||
}
|
||||
|
||||
/** 图标颜色:品牌深色实色 */
|
||||
function toSolidColor(rgba : string) {
|
||||
return rgba.replace('0.95)', '1)')
|
||||
/** 图标颜色:品牌深色实色(#rrggbbaa 后两位替换为 FF,不透明) */
|
||||
function toSolidColor(hex8 : string) {
|
||||
return (hex8 || '').replace(/(#[0-9a-fA-F]{6})[0-9a-fA-F]{2}$/, (_m, base) => `${base}FF`)
|
||||
}
|
||||
|
||||
/** 收藏导航项右侧文案跟随收藏总数(收藏页返回/切回时刷新) */
|
||||
@@ -188,7 +188,7 @@
|
||||
title: e.title || '',
|
||||
iconPrefix: e.iconPrefix,
|
||||
icon: e.icon || '',
|
||||
bgColor: e.bgColor || 'rgba(150, 150, 150, 0.95)',
|
||||
bgColor: e.bgColor || '#969696F2',
|
||||
color: e.color,
|
||||
rightText: e.subTitle || '',
|
||||
path: e.path || null,
|
||||
@@ -216,7 +216,7 @@
|
||||
title: '我的收藏',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-smiling',
|
||||
bgColor: 'rgba(255, 179, 0, 0.95)',
|
||||
bgColor: '#FFB300F2',
|
||||
rightText: '',
|
||||
path: '/pages-blog/favorites/favorites',
|
||||
show: true,
|
||||
@@ -227,7 +227,7 @@
|
||||
title: '数据看板',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-surprised',
|
||||
bgColor: 'rgba(102, 60, 201, 0.95)',
|
||||
bgColor: '#663CC9F2',
|
||||
rightText: '站点数据可视化',
|
||||
path: '/pages-blog/data-visual/data-visual',
|
||||
show: dataVisualAvailable,
|
||||
@@ -238,7 +238,7 @@
|
||||
title: calcAuditModeEnabled.value ? '内容归档' : '文章归档',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-mask',
|
||||
bgColor: 'rgba(3, 169, 244, 0.95)',
|
||||
bgColor: '#03A9F4F2',
|
||||
rightText: calcAuditModeEnabled.value ? '全部已归档内容' : '全部已归档文章',
|
||||
path: '/pages-blog/archives/archives',
|
||||
show: true,
|
||||
@@ -249,7 +249,7 @@
|
||||
title: '恋爱日记',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-in-love',
|
||||
bgColor: 'rgba(255, 76, 103, 0.95)',
|
||||
bgColor: '#FF4C67F2',
|
||||
rightText: '博主的恋爱日记',
|
||||
path: '/pages-blog/love/love',
|
||||
show: loveEnabled.value,
|
||||
@@ -261,7 +261,7 @@
|
||||
title: '投票中心',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-confused',
|
||||
bgColor: 'rgba(0, 188, 212, 0.95)',
|
||||
bgColor: '#00BCD4F2',
|
||||
rightText: '查看和进行投票',
|
||||
path: '/pages-blog/votes/votes',
|
||||
show: !calcAuditModeEnabled.value && voteAvailable,
|
||||
@@ -273,7 +273,7 @@
|
||||
title: '友情链接',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-cool',
|
||||
bgColor: 'rgba(0, 150, 136, 0.95)',
|
||||
bgColor: '#009688F2',
|
||||
rightText: '看看博主朋友们吧',
|
||||
path: '/pages-blog/friend-links/friend-links',
|
||||
show: linksAvailable,
|
||||
@@ -285,7 +285,7 @@
|
||||
title: '免责声明',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-smirking',
|
||||
bgColor: 'rgba(121, 85, 72, 0.95)',
|
||||
bgColor: '#795548F2',
|
||||
rightText: '博客内容免责声明',
|
||||
path: '/pages-blog/disclaimers/disclaimers',
|
||||
// 2026-09-10 起无 enabled 开关,按内容非空判定入口显隐
|
||||
@@ -298,7 +298,7 @@
|
||||
title: '联系博主',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-wink',
|
||||
bgColor: 'rgba(255, 152, 0, 0.95)',
|
||||
bgColor: '#FF9800F2',
|
||||
rightText: '博主常用联系方式',
|
||||
path: '/pages-blog/contact/contact',
|
||||
show: socialEnabled.value,
|
||||
@@ -310,7 +310,7 @@
|
||||
title: '关于项目',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-happy-',
|
||||
bgColor: 'rgba(96, 125, 139, 0.95)',
|
||||
bgColor: '#607D8BF2',
|
||||
rightText: '小莫唐尼开源项目',
|
||||
path: '/pages-blog/about/about',
|
||||
// showAboutSystem 2026-09-10 下线(入口由插件端功能入口 myPageConfig 统一管理),默认展示
|
||||
@@ -323,7 +323,7 @@
|
||||
title: '偏好设置',
|
||||
iconPrefix: 'uhemoji2-icon',
|
||||
icon: '-tired',
|
||||
bgColor: 'rgba(121, 134, 203, 0.95)',
|
||||
bgColor: '#7986CBF2',
|
||||
rightText: '首页布局、卡片样式等本地偏好',
|
||||
path: '/pages-blog/setting/setting',
|
||||
show: true,
|
||||
|
||||
+2
-13
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* 应用配置 store(源自旧项目 store/config.js 的 configs/auditData 部分)
|
||||
* 注意:旧 fetchConfigs 中会把 basicConfig.tokenConfig 写入缓存,供 getPersonalToken 使用,此处保留
|
||||
* 应用配置
|
||||
*/
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
@@ -10,8 +9,6 @@ import { deepMerge } from '@/utils/merge'
|
||||
import { setCache } from '@/utils/storage'
|
||||
import type { IAppConfig, IAuditDataResult } from '@/api/types/uni-halo'
|
||||
|
||||
/** 个人令牌存储 key(与 src/store/token.ts 的 getPersonalToken 保持一致) */
|
||||
const APP_TOKENS_KEY = 'APP_TOKENS'
|
||||
/** 合并后配置缓存 key(与 utils/url.ts / api/uni-halo.ts 的 APP_GLOBAL_CONFIGS 读取保持一致) */
|
||||
const APP_GLOBAL_CONFIGS_KEY = 'APP_GLOBAL_CONFIGS'
|
||||
/**
|
||||
@@ -30,8 +27,7 @@ export interface IStaticLoveConfig {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 静态配置后台刷新间隔(ms): onShow 距上次拉取在 TTL 内则不再重复请求(设计见
|
||||
* .docs/static-config-unified-fetch-design.md)
|
||||
* 静态配置后台刷新间隔(ms): onShow 距上次拉取在 TTL 内则不再重复请求
|
||||
*/
|
||||
const STATIC_TTL = 5 * 60 * 1000
|
||||
|
||||
@@ -65,14 +61,7 @@ export const useAppConfigStore = defineStore(
|
||||
if (body) {
|
||||
configs.value = deepMerge(JSON.parse(JSON.stringify(DefaultAppConfigs)), body)
|
||||
|
||||
// 合并结果写入 APP_GLOBAL_CONFIGS 缓存,供 utils/url.ts 图片兜底与
|
||||
// api/uni-halo.ts 第三方插件授权头等按 storage 路径读取
|
||||
setCache(APP_GLOBAL_CONFIGS_KEY, configs.value)
|
||||
|
||||
// 存储个人令牌(供 getPersonalToken 使用,如非匿名投票)
|
||||
if (body?.basicConfig?.tokenConfig) {
|
||||
setCache(APP_TOKENS_KEY, body.basicConfig.tokenConfig)
|
||||
}
|
||||
return body
|
||||
}
|
||||
setDefaultAppSettings()
|
||||
|
||||
Reference in New Issue
Block a user