1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-11-13 22:11:42 +08:00

feat: 联系博主页对接博主介绍/社交动态列表,下线友链提交页

- contact.vue:博主介绍(intro 富文本)用 mp-html 完整配置渲染(domain/loading-img/
  tag-style/container-style/markdown,对齐 moments/文章详情);社交信息改读
  authorConfig.social.items 动态列表(priority 排序、visible 过滤、未配置空态、
  不回退默认值),去 enabled 开关;收信日期改 formatTime 实时显示
- about.vue:社交入口判定改按社交项列表(存在可见且有内容即展示)
- 友链提交功能调整:submit-link 页面下线,mini-info/site-info 与提交开关
  (submissionEnabled)随插件端新结构对接

Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
This commit is contained in:
小莫唐尼
2026-09-10 19:13:42 +08:00
parent 0c1c71a290
commit 4eae337a8e
9 changed files with 209 additions and 375 deletions
+139 -132
View File
@@ -1,148 +1,155 @@
<script lang="ts" setup>
import { computed, ref, watch, watchEffect } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { checkAvatarUrl } from '@/utils/url'
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { useAppConfigStore } from '@/store/appConfig'
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
import { checkAvatarUrl } from '@/utils/url'
import { formatTime } from '@/utils/formatTime'
import { markdownConfig } from '@/config/markdown'
definePage({
style: {
navigationBarTitleText: '联系博主',
navigationStyle: 'custom',
},
})
definePage({
style: {
navigationBarTitleText: '联系博主',
navigationStyle: 'custom',
},
})
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
interface ISoical {
key ?: string
name : string
content : string
icon ?: string,
color : string,
bgColor : string,
priority ?: number,
visible ?: boolean,
}
const bloggerInfo = computed(() => {
const blogger = authorConfig.value?.blogger as { nickname?: string, avatar?: string, description?: string } | undefined
return {
nickname: blogger?.nickname || '',
avatar: checkAvatarUrl(blogger?.avatar),
description: blogger?.description || '',
}
})
const appConfigStore = useAppConfigStore()
const authorConfig = computed(() => appConfigStore.configs.authorConfig)
const socialConfig = computed(() => (authorConfig.value?.social as Record<string, unknown> | undefined) || {})
const bloggerInfo = computed(() => {
const blogger = authorConfig.value?.blogger as { nickname ?: string, avatar ?: string, description ?: string, intro ?: string } | undefined
return {
nickname: blogger?.nickname || '',
avatar: checkAvatarUrl(blogger?.avatar),
description: blogger?.description || '',
intro: blogger?.intro || '',
}
})
/** 联系方式列表(从配置填充) */
const result = ref<{ key: string, name: string, value: string }[]>([
{ key: 'qq', name: '企鹅号', value: '' },
{ key: 'wechat', name: '微信号', value: '' },
{ key: 'github', name: 'Github', value: '' },
{ key: 'gitee', name: 'Gitee', value: '' },
{ key: 'bilibili', name: 'Bilibili', value: '' },
{ key: 'csdn', name: 'CSDN', value: '' },
{ key: 'blog', name: '博客地址', value: '' },
{ key: 'juejin', name: '掘金地址', value: '' },
{ key: 'weibo', name: '微博地址', value: '' },
{ key: 'email', name: '邮箱地址', value: '' },
])
const socialConfig = computed(() => (authorConfig.value?.social as { items ?: ISoical[] } | undefined) || {})
/** 平台瓦片(品牌色 + 字符);未覆盖的平台回退中性色与名称首字 */
const platformMeta: Record<string, { color: string, letter: string }> = {
qq: { color: '#12b7f5', letter: 'Q' },
wechat: { color: '#07c160', letter: '微' },
github: { color: '#24292f', letter: 'G' },
gitee: { color: '#c71d23', letter: 'G' },
bilibili: { color: '#fb7299', letter: 'B' },
csdn: { color: '#fc5531', letter: 'C' },
blog: { color: '#3f51b5', letter: '博' },
juejin: { color: '#1e80ff', letter: '掘' },
weibo: { color: '#e6162d', letter: 'W' },
email: { color: '#f57c00', letter: '@' },
}
const socialList = computed<Array<ISoical>>(() => {
const configured = socialConfig.value.items
if (!configured || !configured.length) {
return []
}
return [...configured]
.filter(item => item.visible !== false)
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
})
const calcIsNotEmpty = computed(() => result.value.some(item => item.value !== ''))
const isNotEmpty = computed(() => socialList.value.some(item => item.visible && !!item.content))
/* ---------------- 加载状态机(本地配置,状态直接推导) ---------------- */
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
watchEffect(() => {
updateLoadingStatus(calcIsNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
})
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
watchEffect(() => {
updateLoadingStatus(isNotEmpty.value ? DataLoadingStatusEnum.Success : DataLoadingStatusEnum.Empty)
})
function handleGetData() {
for (const key in socialConfig.value) {
if (key === 'enabled')
continue
const item = result.value.find(x => x.key === key)
if (item) {
item.value = String(socialConfig.value[key] || '')
}
}
}
function handleOnClick(item : ISoical) {
if (!item.content) { return }
uni.setClipboardData({
data: item.content,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
},
})
}
function handleOnClick(item: { value: string, name: string }) {
if (!item.value)
return
uni.setClipboardData({
data: item.value,
showToast: false,
success: () => {
uni.showToast({ icon: 'none', title: `${item.name} 已复制!` })
},
})
}
watch(socialConfig, () => {
handleGetData()
}, { deep: true, immediate: true })
/* ---------------- 实时时间(收信日期,formatTime 工具每秒刷新) ---------------- */
const nowText = ref('')
let clock : ReturnType<typeof setInterval> | null = null
function refreshNowText() {
nowText.value = formatTime({ d: Date.now(), f: 'yyyy年MM月dd日' })
}
refreshNowText()
clock = setInterval(refreshNowText, 1000)
onUnmounted(() => {
if (clock) {
clearInterval(clock)
}
})
</script>
<template>
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
<!-- 自定义导航 -->
<uh-navbar default-title="联系博主" title-color="text-gray-900" />
<view class="box-border min-h-screen w-screen overflow-hidden bg-page px-4 pb-10 pt-2">
<!-- 自定义导航 -->
<uh-navbar default-title="联系博主" title-color="text-gray-900" />
<!-- Hero 名片卡(主题色光斑透过毛玻璃形成柔和渐变) -->
<view class="hero-wrap relative">
<view class="absolute h-[220rpx] w-[220rpx] rounded-full bg-[rgba(185,228,36,0.32)] -right-8 -top-8" />
<view class="absolute top-[150rpx] h-[180rpx] w-[180rpx] rounded-full bg-[rgba(215,249,76,0.45)] -left-10" />
<view class="hero-card uh-global-card-glass uh-shadow-xs relative flex flex-col items-center rounded-2xl px-6 pb-6 pt-10">
<view class="avatar relative box-border h-[150rpx] w-[150rpx] overflow-hidden border-5 border-white/90 rounded-full shadow-lg">
<image class="avatar-img h-full w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
</view>
<view class="nickname mt-4 text-[38rpx] text-gray-900 font-bold">
{{ bloggerInfo.nickname }}
</view>
<view class="desc mt-2 px-4 text-center text-[26rpx] text-gray-500 leading-relaxed">
{{ bloggerInfo.description || '这个博主很懒,竟然没写介绍~' }}
</view>
<view class="mt-5 w-full flex items-center justify-center gap-2 border-t border-black/5 pt-4">
<wd-icon name="copy" size="26rpx" color="#a8a294" />
<text class="text-2xs text-gray-400">点击卡片即可复制对应内容</text>
</view>
</view>
</view>
<view class="fixed -right-8 top-8 h-28 w-28 rounded-full bg-[rgba(185,228,36,0.32)] blur-xl" />
<view class="fixed -left-10 top-36 h-24 w-24 rounded-full bg-[rgba(215,249,76,0.45)] blur-xl" />
<!-- 联系方式(状态机:无联系方式 → empty 态) -->
<uh-data-loading
v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="30vh"
empty-text="暂无联系方式" empty-sub-text="" @refresh="handleGetData"
/>
<template v-else>
<uh-section-title class="mb-3 mt-6">
联系方式
</uh-section-title>
<view class="flex flex-col gap-3">
<view
v-for="item in result.filter(i => i.value)"
:key="item.key"
class="box-border uh-global-card-glass uh-shadow-xs flex items-center gap-3 rounded-2xl px-4 py-3"
@click="handleOnClick(item)"
>
<view class="tile h-[76rpx] w-[76rpx] flex shrink-0 items-center justify-center rounded-xl" :style="{ backgroundColor: platformMeta[item.key]?.color || '#8a8a7a' }">
<text class="text-[30rpx] text-white font-bold">{{ platformMeta[item.key]?.letter || item.name.slice(0, 1) }}</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-[26rpx] text-gray-900 leading-snug">
{{ item.value }}
</view>
</view>
<wd-icon name="copy" size="28rpx" class="shrink-0 text-gray-400" />
</view>
</view>
</template>
</view>
</template>
<view
class="box-border relative flex items-center justify-between uh-global-card-glass uh-shadow-xs rounded-xl p-4">
<view class="flex-1 relative flex flex-col rounded-2xl">
<view class="flex items-center gap-x-2 text-xs text-primary">
TO <text class="text-sm">·</text> 收
</view>
<view class="mt-2 text-md text-gray-900 tracking-wider">
素未谋面的朋友
</view>
<view class="mt-2 text-xs text-black/60">
展信安,见字如面。
</view>
<view class="mt-3 text-xs text-black/60">
自 · {{ bloggerInfo.nickname }}
</view>
</view>
<view
class="shrink-0 uh-global-card-glass uh-shadow-xs border relative rotate-3 box-border w-22 overflow-hidden flex flex-col gap-y-1 items-center justify-center p-2">
<image class="h-18 w-full" :src="bloggerInfo.avatar" mode="aspectFill" />
<text class="text-xs font-normal truncate">{{ bloggerInfo.nickname }}</text>
</view>
</view>
<view class="mt-4 flex flex-col gap-y-6 box-border uh-global-card-glass uh-shadow-xs rounded-xl px-4 py-3">
<uh-data-loading v-if="loadingStatus !== 'success'" :loading-status="loadingStatus" min-height="65vh"
empty-text="暂无联系方式" empty-sub-text="" />
<template v-else>
<view class="w-full flex flex-col gap-y-3">
<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 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>
</view>
</view>
<view class="box-border pt-4 w-full flex flex-col gap-y-2 border-t border-t-dashed border-gray-200">
<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"
:style="{ backgroundColor: item.bgColor ,color:item.color }">
<text class="text-sm text-gray-500 font-bold"> {{ item.icon }} </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">
{{ item.content }}
</view>
</view>
<wd-icon name="copy" size="28rpx" class="shrink-0 text-primary" />
</view>
</view>
</template>
</view>
</view>
</template>