feat: init admin repo
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<h3 class="m-0 text-base font-760 text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-map-marker-outline text-lg tone-accent"></span>
|
||||
高德地图服务 API 配置
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1">用于后台恋爱足迹管理中的地图选点定位、反向地址解析。</p>
|
||||
</div>
|
||||
<n-button
|
||||
secondary
|
||||
strong
|
||||
size="small"
|
||||
tag="a"
|
||||
:href="getBlogUrl('/writing/amap-guide')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="archive-btn shrink-0"
|
||||
>
|
||||
<template #icon><span class="i-mdi-help-circle-outline"></span></template>
|
||||
查看配置文档
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-form label-placement="top" class="mt-5 space-y-4">
|
||||
<n-form-item label="高德地图 Web端 API Key" required>
|
||||
<n-input v-model:value="amap.key" type="password" show-password-on="click" placeholder="输入高德地图开发平台申请的 Web端 JS Key" />
|
||||
</n-form-item>
|
||||
<n-form-item label="高德地图安全密钥 (SecurityJsCode)" required>
|
||||
<n-input v-model:value="amap.securityJsCode" type="password" show-password-on="click" placeholder="输入高德地图 API 安全密钥" />
|
||||
</n-form-item>
|
||||
|
||||
<div class="soft-panel p-3.5 bg-neutral-500/5 border border-neutral-500/10 rounded-2xl flex items-start gap-3">
|
||||
<span class="i-mdi-alert-circle-outline tone-muted mt-0.5 text-base"></span>
|
||||
<div>
|
||||
<p class="m-0 text-xs font-700 tone-muted">安全提示</p>
|
||||
<p class="m-0 mt-0.5 text-[11px] leading-relaxed tone-faint">
|
||||
保存时,高德密钥将在前端进行混淆加密后提交至数据库,防范明文传输与泄露风险。拉取展示时以星号(*)掩码呈现。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-(--archive-border)/40 pt-4 mt-2 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
保存地图配置
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
const getBlogUrl = (path: string) => {
|
||||
const protocol = window.location.protocol
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '127.0.0.1') {
|
||||
return `${protocol}//localhost:3000${path}`
|
||||
}
|
||||
if (hostname.startsWith('admin.')) {
|
||||
const mainDomain = hostname.replace('admin.', '')
|
||||
return `${protocol}//${mainDomain}${path}`
|
||||
}
|
||||
return `${protocol}//${hostname}${path}`
|
||||
}
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const amap = ref({
|
||||
key: '',
|
||||
securityJsCode: ''
|
||||
})
|
||||
|
||||
const rawAmapKey = ref('')
|
||||
const rawAmapSecurityJsCode = ref('')
|
||||
const SALT = "ArchiveAmapSalt_2026"
|
||||
|
||||
const encryptKey = (str: string): string => {
|
||||
if (!str) return ''
|
||||
if (str.startsWith('enc_v2:') || str.startsWith('enc:')) return str
|
||||
try {
|
||||
let xorStr = ''
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const charCode = str.charCodeAt(i) ^ SALT.charCodeAt(i % SALT.length)
|
||||
xorStr += String.fromCharCode(charCode)
|
||||
}
|
||||
const bytes = new TextEncoder().encode(xorStr)
|
||||
let binary = ''
|
||||
const len = bytes.byteLength
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(bytes[i])
|
||||
}
|
||||
return 'enc_v2:' + btoa(binary)
|
||||
} catch (e) {
|
||||
const shifted = str.split('').map(c => String.fromCharCode(c.charCodeAt(0) + 3)).join('')
|
||||
return 'enc:' + btoa(encodeURIComponent(shifted))
|
||||
}
|
||||
}
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('satoken')
|
||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
const list = response.data.data || []
|
||||
const getValue = (key: string, def: string) => {
|
||||
const item = list.find((c: any) => c.configKey === key)
|
||||
return item ? item.configValue : def
|
||||
}
|
||||
|
||||
rawAmapKey.value = getValue('page.footprint.amap.key', '')
|
||||
rawAmapSecurityJsCode.value = getValue('page.footprint.amap.securityJsCode', '')
|
||||
|
||||
amap.value.key = rawAmapKey.value ? '●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●' : ''
|
||||
amap.value.securityJsCode = rawAmapSecurityJsCode.value ? '●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●' : ''
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load map configs', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
const token = localStorage.getItem('satoken')
|
||||
|
||||
let finalKey = amap.value.key
|
||||
if (finalKey === '●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●') {
|
||||
finalKey = rawAmapKey.value
|
||||
} else {
|
||||
finalKey = encryptKey(finalKey)
|
||||
}
|
||||
|
||||
let finalCode = amap.value.securityJsCode
|
||||
if (finalCode === '●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●') {
|
||||
finalCode = rawAmapSecurityJsCode.value
|
||||
} else {
|
||||
finalCode = encryptKey(finalCode)
|
||||
}
|
||||
|
||||
const payload = [
|
||||
{ configKey: 'page.footprint.amap.key', configValue: finalKey, description: '高德地图 API Key (JS端)' },
|
||||
{ configKey: 'page.footprint.amap.securityJsCode', configValue: finalCode, description: '高德地图 API 安全密钥 (SecurityJsCode)' }
|
||||
]
|
||||
|
||||
try {
|
||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success('地图服务配置已成功保存')
|
||||
await fetchConfigs()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '网络连接失败,配置保存失败。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfigs()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||
<h3 class="m-0 text-base font-760 text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-shield-check-outline text-lg tone-accent"></span>
|
||||
站点备案与合规管理
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1">配置博客页脚展示的工信部 ICP 备案号和公安联网备案号及其相应的跳转链接。</p>
|
||||
|
||||
<n-form label-placement="top" class="mt-6 space-y-4 max-w-xl">
|
||||
<n-form-item label="工信部 ICP 备案号">
|
||||
<n-input v-model:value="beian.icp" placeholder="例如: 滇ICP备2025004561号-1" class="archive-input" clearable />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="工信部 ICP 备案跳转链接">
|
||||
<n-input v-model:value="beian.icpUrl" placeholder="例如: https://beian.miit.gov.cn/" class="archive-input" clearable />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="公安联网备案号">
|
||||
<n-input v-model:value="beian.police" placeholder="例如: 滇公网安备 53090202000123号" class="archive-input" clearable />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="公安联网备案跳转链接">
|
||||
<n-input v-model:value="beian.policeUrl" placeholder="例如: http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=53090202000123" class="archive-input" clearable />
|
||||
</n-form-item>
|
||||
|
||||
<div class="pt-2 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" class="archive-btn" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
应用备案配置
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const beian = ref({
|
||||
icp: '',
|
||||
icpUrl: 'https://beian.miit.gov.cn/',
|
||||
police: '',
|
||||
policeUrl: ''
|
||||
})
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('satoken')
|
||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
const list = response.data.data || []
|
||||
const getValue = (key: string, def: string) => {
|
||||
const item = list.find((c: any) => c.configKey === key)
|
||||
return item ? item.configValue : def
|
||||
}
|
||||
|
||||
beian.value.icp = getValue('site.beian.icp', '')
|
||||
beian.value.icpUrl = getValue('site.beian.icpUrl', 'https://beian.miit.gov.cn/')
|
||||
beian.value.police = getValue('site.beian.police', '')
|
||||
beian.value.policeUrl = getValue('site.beian.policeUrl', '')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load beian config', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
const token = localStorage.getItem('satoken')
|
||||
|
||||
const payload = [
|
||||
{ configKey: 'site.beian.icp', configValue: beian.value.icp || '', description: '工信部ICP备案号' },
|
||||
{ configKey: 'site.beian.icpUrl', configValue: beian.value.icpUrl || 'https://beian.miit.gov.cn/', description: '工信部ICP备案跳转链接' },
|
||||
{ configKey: 'site.beian.police', configValue: beian.value.police || '', description: '公安联网备案号' },
|
||||
{ configKey: 'site.beian.policeUrl', configValue: beian.value.policeUrl || '', description: '公安联网备案跳转链接' }
|
||||
]
|
||||
|
||||
try {
|
||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success('备案信息配置应用成功!')
|
||||
window.dispatchEvent(new CustomEvent('atlas-config-changed'))
|
||||
await fetchConfigs()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '配置保存失败,请检查连接。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfigs()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.archive-input :deep(.n-input-wrapper) {
|
||||
border-radius: 10px;
|
||||
}
|
||||
.archive-btn {
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,376 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl text-left">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="m-0 text-base font-bold text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-flower text-lg text-(--archive-accent) animate-pulse"></span>
|
||||
全站品牌与开屏配置 (Brand & Welcome Hero)
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1 leading-relaxed">
|
||||
自定义全站 LOGO 图标、文字标识、浏览器 Favicon 标签图标、网页标题文案,以及主页开屏的微缩微粒文本和背景大图/视频。
|
||||
</p>
|
||||
</div>
|
||||
<n-button secondary size="small" type="warning" @click="handleResetDefault">
|
||||
恢复系统默认
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-form label-placement="top" class="mt-6 space-y-5">
|
||||
<!-- 1. 网站标识配置 -->
|
||||
<div class="space-y-4">
|
||||
<p class="m-0 text-xs font-bold border-b border-(--archive-border)/40 pb-2 mb-3 text-(--archive-text)">全站导航 LOGO & 品牌文字</p>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 items-start">
|
||||
<n-form-item label="Logo 旁边展示文字 (Logo Text)" required class="m-0">
|
||||
<n-input v-model:value="brand.logoText" placeholder="例如: RRTiamo" class="archive-input w-full" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="Logo 图标图片 (Logo URL - 留空默认使用 SVG 齿轮)" class="m-0">
|
||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-2 w-full overflow-hidden">
|
||||
<n-input v-model:value="brand.logoUrl" placeholder="图片 URL..." class="font-mono flex-1 archive-input" clearable />
|
||||
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
||||
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('logoUrl')">相册选择</n-button>
|
||||
<n-upload
|
||||
action="http://localhost:8080/api/blogs/upload?type=brand"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
class="flex shrink-0"
|
||||
@finish="(res) => handleUploadFinish('logoUrl', res)"
|
||||
@error="handleUploadError"
|
||||
>
|
||||
<n-button secondary size="small" type="primary">
|
||||
上传
|
||||
</n-button>
|
||||
</n-upload>
|
||||
<!-- Logo 预览 -->
|
||||
<div v-if="brand.logoUrl" class="h-8 w-8 rounded-lg border border-(--archive-border)/40 bg-black/5 overflow-hidden flex items-center justify-center shrink-0">
|
||||
<img :src="brand.logoUrl" class="w-full h-full object-contain" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2. 标签页与 SEO 配置 -->
|
||||
<div class="space-y-4 pt-3">
|
||||
<p class="m-0 text-xs font-bold border-b border-(--archive-border)/40 pb-2 mb-3 text-(--archive-text)">浏览器标签 Favicon & 网页标题 (SEO)</p>
|
||||
|
||||
<n-form-item label="浏览器 Favicon 标签图标 (Favicon URL - 留空默认使用彩色小花)">
|
||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-2 w-full overflow-hidden">
|
||||
<n-input v-model:value="brand.faviconUrl" placeholder="图片 URL..." class="font-mono flex-1 archive-input" clearable />
|
||||
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
||||
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('faviconUrl')">相册选择</n-button>
|
||||
<n-upload
|
||||
action="http://localhost:8080/api/blogs/upload?type=brand"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
class="flex shrink-0"
|
||||
@finish="(res) => handleUploadFinish('faviconUrl', res)"
|
||||
@error="handleUploadError"
|
||||
>
|
||||
<n-button secondary size="small" type="primary">
|
||||
上传
|
||||
</n-button>
|
||||
</n-upload>
|
||||
<!-- Favicon 预览 -->
|
||||
<div v-if="brand.faviconUrl" class="h-8 w-8 rounded-lg border border-(--archive-border)/40 bg-black/5 overflow-hidden flex items-center justify-center shrink-0">
|
||||
<img :src="brand.faviconUrl" class="w-full h-full object-contain" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</n-form-item>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-2">
|
||||
<n-form-item label="全站默认浏览器标签标题 (Default Title)" required>
|
||||
<n-input v-model:value="brand.titleDefault" placeholder="例如: 此间主人 | RRTiamo" class="archive-input" />
|
||||
</n-form-item>
|
||||
<n-form-item label="关于作者页面专属浏览器标签标题 (About Page Title)" required>
|
||||
<n-input v-model:value="brand.titleAbout" placeholder="例如: 春风不解别离意,今日方知我是春。" class="archive-input" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. 主页开屏定制 -->
|
||||
<div class="space-y-4 pt-3">
|
||||
<p class="m-0 text-xs font-bold border-b border-(--archive-border)/40 pb-2 mb-3 text-(--archive-text)">主页开屏文本与定制媒体背景 (Welcome Hero)</p>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<n-form-item label="开屏品牌英文/拼音大字 (Welcome Large Text)" required>
|
||||
<n-input v-model:value="brand.welcomeText" placeholder="例如: spring" class="archive-input font-mono" />
|
||||
</n-form-item>
|
||||
<n-form-item label="开屏打字机底部小字 (Welcome Subtitle)" required>
|
||||
<n-input v-model:value="brand.welcomeSubtitle" placeholder="例如: 此间主人" class="archive-input" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<n-form-item label="开屏背景展示媒体 (大图/视频 URL)">
|
||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-2 w-full overflow-hidden">
|
||||
<n-input v-model:value="brand.heroBgUrl" placeholder="输入外部图片或视频链接..." class="font-mono flex-1 archive-input" clearable />
|
||||
<div class="flex items-center gap-2 shrink-0 justify-end sm:justify-start">
|
||||
<n-button secondary size="small" class="shrink-0" @click="openGallerySelect('heroBgUrl')">相册选择</n-button>
|
||||
<n-upload
|
||||
action="http://localhost:8080/api/blogs/upload?type=brand"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
class="flex shrink-0"
|
||||
@finish="(res) => handleUploadFinish('heroBgUrl', res)"
|
||||
@error="handleUploadError"
|
||||
>
|
||||
<n-button secondary size="small" type="primary">
|
||||
上传
|
||||
</n-button>
|
||||
</n-upload>
|
||||
<!-- 开屏背景预览 -->
|
||||
<div v-if="brand.heroBgUrl" class="h-8 w-12 rounded-lg border border-(--archive-border)/40 bg-black/10 overflow-hidden flex items-center justify-center shrink-0">
|
||||
<video v-if="isMediaVideo(brand.heroBgUrl)" :src="brand.heroBgUrl" autoplay muted loop playsinline class="w-full h-full object-cover"></video>
|
||||
<img v-else :src="brand.heroBgUrl" class="w-full h-full object-cover" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<!-- 提交控制 -->
|
||||
<div class="border-t border-(--archive-border)/40 pt-4 mt-4 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
应用品牌与开屏配置
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
|
||||
<!-- 从照片墙图册选择弹窗 -->
|
||||
<n-modal
|
||||
v-model:show="showGallerySelectModal"
|
||||
preset="card"
|
||||
title="从相册选择媒体文件"
|
||||
class="w-[95vw] max-w-[700px] rounded-2xl"
|
||||
>
|
||||
<div v-if="loadingGallery" class="py-12 flex justify-center">
|
||||
<n-spin size="medium" />
|
||||
</div>
|
||||
<div v-else-if="galleryPhotos.length === 0" class="py-12 text-center">
|
||||
<span class="i-mdi-image-off-outline text-5xl tone-muted opacity-60"></span>
|
||||
<p class="text-xs tone-muted mt-2">您的相册库空空如应,请先在「照片墙」管理中添加照片。</p>
|
||||
</div>
|
||||
<div v-else class="space-y-4">
|
||||
<p class="text-xs tone-muted leading-relaxed">
|
||||
点击选择下方图册中的照片或视频,点击「确认选择」后即可应用到对应配置项。
|
||||
</p>
|
||||
|
||||
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 max-h-[50vh] overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="photo in galleryPhotos"
|
||||
:key="photo.id"
|
||||
class="group relative aspect-[3/2] rounded-xl overflow-hidden border transition-all cursor-pointer bg-black/5"
|
||||
:class="[
|
||||
selectedPhotoUrl === photo.src
|
||||
? 'border-(--archive-accent) ring-2 ring-(--archive-accent) ring-offset-2 dark:ring-offset-neutral-900'
|
||||
: 'border-(--archive-border)/40 hover:border-(--archive-accent)/60'
|
||||
]"
|
||||
@click="selectedPhotoUrl = photo.src"
|
||||
>
|
||||
<video
|
||||
v-if="photo.type === 'video'"
|
||||
:src="photo.src"
|
||||
class="w-full h-full object-cover"
|
||||
preload="metadata"
|
||||
muted
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
:src="photo.src"
|
||||
:alt="photo.title"
|
||||
class="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
<div v-if="photo.type === 'video'" class="absolute right-2 top-2 z-10 flex h-5 w-5 items-center justify-center rounded-full bg-black/50 text-white backdrop-blur-sm pointer-events-none">
|
||||
<span class="i-mdi-video text-xs"></span>
|
||||
</div>
|
||||
<div v-if="selectedPhotoUrl === photo.src" class="absolute inset-0 bg-[color-mix(in_srgb,var(--archive-accent)_15%,transparent)] flex items-center justify-center">
|
||||
<span class="i-mdi-check-circle text-2xl text-(--archive-accent) drop-shadow-md"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #action>
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<n-button size="small" round @click="showGallerySelectModal = false">取消</n-button>
|
||||
<n-button type="primary" size="small" round :disabled="!selectedPhotoUrl" @click="confirmGallerySelect">确认选择</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NInput, NUpload, NButton, NModal, NSpin } from 'naive-ui'
|
||||
import { getConfigList, updateConfigBatch } from '@/api/config'
|
||||
import { getFileList } from '@/api/files'
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const defaultBrand = {
|
||||
logoUrl: '',
|
||||
logoText: 'RRTiamo',
|
||||
faviconUrl: '',
|
||||
titleDefault: '此间主人 | RRTiamo',
|
||||
titleAbout: '春风不解别离意,今日方知我是春。',
|
||||
welcomeText: 'spring',
|
||||
welcomeSubtitle: '此间主人',
|
||||
heroBgUrl: '/assets/bg-video.mp4'
|
||||
}
|
||||
|
||||
const brand = ref({ ...defaultBrand })
|
||||
|
||||
// 照片墙弹窗相关
|
||||
const showGallerySelectModal = ref(false)
|
||||
const loadingGallery = ref(false)
|
||||
const galleryPhotos = ref<any[]>([])
|
||||
const selectedPhotoUrl = ref('')
|
||||
const gallerySelectTarget = ref<'logoUrl' | 'faviconUrl' | 'heroBgUrl'>('logoUrl')
|
||||
|
||||
const uploadHeaders = computed(() => ({
|
||||
satoken: localStorage.getItem('satoken') || ''
|
||||
}))
|
||||
|
||||
const isMediaVideo = (url: string) => {
|
||||
if (!url) return false
|
||||
return /\.(mp4|webm|ogg|mov|m4v)($|\?)/i.test(url)
|
||||
}
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
try {
|
||||
const response = await getConfigList()
|
||||
if (response.data && response.data.code === 200) {
|
||||
const list = response.data.data || []
|
||||
const getValue = (key: string, def: string) => {
|
||||
const item = list.find((c: any) => c.configKey === key)
|
||||
return item ? item.configValue : def
|
||||
}
|
||||
|
||||
brand.value.logoUrl = getValue('site.logo.url', '')
|
||||
brand.value.logoText = getValue('site.logo.text', 'RRTiamo')
|
||||
brand.value.faviconUrl = getValue('site.favicon.url', '')
|
||||
brand.value.titleDefault = getValue('site.title.default', '此间主人 | RRTiamo')
|
||||
brand.value.titleAbout = getValue('site.title.about', '春风不解别离意,今日方知我是春。')
|
||||
brand.value.welcomeText = getValue('page.home.welcomeText', 'spring')
|
||||
brand.value.welcomeSubtitle = getValue('page.home.welcomeSubtitle', '此间主人')
|
||||
brand.value.heroBgUrl = getValue('page.home.heroBgUrl', '/assets/bg-video.mp4')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load brand config', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
|
||||
const payload = [
|
||||
{ configKey: 'site.logo.url', configValue: brand.value.logoUrl, description: '全站 LOGO 自定义图片链接' },
|
||||
{ configKey: 'site.logo.text', configValue: brand.value.logoText, description: '网站 LOGO 旁边的展示文字' },
|
||||
{ configKey: 'site.favicon.url', configValue: brand.value.faviconUrl, description: '浏览器 Tab 标签 Favicon 图片链接' },
|
||||
{ configKey: 'site.title.default', configValue: brand.value.titleDefault, description: '全站默认网页 Title 标题' },
|
||||
{ configKey: 'site.title.about', configValue: brand.value.titleAbout, description: '关于作者页专属网页 Title 标题' },
|
||||
{ configKey: 'page.home.welcomeText', configValue: brand.value.welcomeText, description: '主页开屏大字文案' },
|
||||
{ configKey: 'page.home.welcomeSubtitle', configValue: brand.value.welcomeSubtitle, description: '主页开屏副标题/打字机小字' },
|
||||
{ configKey: 'page.home.heroBgUrl', configValue: brand.value.heroBgUrl, description: '主页开屏背景图/视频 URL' }
|
||||
]
|
||||
|
||||
try {
|
||||
const response = await updateConfigBatch(payload)
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success('全站品牌与开屏配置应用成功,前台已实时生效!')
|
||||
window.dispatchEvent(new CustomEvent('atlas-config-changed'))
|
||||
await fetchConfigs()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存配置失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '网络连接异常,配置提交失败。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleResetDefault = () => {
|
||||
brand.value = { ...defaultBrand }
|
||||
message.success('已重置为默认品牌配置,请点击右下角应用生效')
|
||||
}
|
||||
|
||||
// 统一本地上传回调
|
||||
const handleUploadFinish = (target: 'logoUrl' | 'faviconUrl' | 'heroBgUrl', { event }: any) => {
|
||||
try {
|
||||
const responseText = (event?.target as any)?.response
|
||||
if (responseText) {
|
||||
const res = JSON.parse(responseText)
|
||||
if (res && res.code === 200 && res.data) {
|
||||
brand.value[target] = res.data
|
||||
message.success('多媒体文件上传成功 🎨')
|
||||
} else {
|
||||
throw new Error(res?.msg || '上传接口错误')
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(`文件上传失败: ${err.message || '解析错误'}`)
|
||||
}
|
||||
}
|
||||
|
||||
const handleUploadError = () => {
|
||||
message.error('文件上传失败,请确认后端服务连接状态 ⚠️')
|
||||
}
|
||||
|
||||
// 照片墙弹窗选择交互
|
||||
const openGallerySelect = async (target: 'logoUrl' | 'faviconUrl' | 'heroBgUrl') => {
|
||||
gallerySelectTarget.value = target
|
||||
showGallerySelectModal.value = true
|
||||
loadingGallery.value = true
|
||||
selectedPhotoUrl.value = brand.value[target] || ''
|
||||
try {
|
||||
const response = await getFileList()
|
||||
if (response.data && response.data.code === 200) {
|
||||
const allFiles = response.data.data || []
|
||||
const imageOrVideoExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'ico', 'mp4', 'mkv', 'avi', 'mov', 'webm']
|
||||
const mapped = allFiles
|
||||
.filter((file: any) => {
|
||||
const name = file.fileName || ''
|
||||
const ext = name.substring(name.lastIndexOf('.') + 1).toLowerCase()
|
||||
return imageOrVideoExtensions.includes(ext)
|
||||
})
|
||||
.map((file: any) => {
|
||||
const name = file.fileName || ''
|
||||
const ext = name.substring(name.lastIndexOf('.') + 1).toLowerCase()
|
||||
const isVid = ['mp4', 'mkv', 'avi', 'mov', 'webm'].includes(ext)
|
||||
return {
|
||||
id: file.fileName,
|
||||
src: file.url,
|
||||
type: isVid ? 'video' : 'image',
|
||||
title: file.fileName
|
||||
}
|
||||
})
|
||||
// Logo 和 Favicon 只能选图片,开屏背景可以选图片/视频
|
||||
galleryPhotos.value = (target === 'logoUrl' || target === 'faviconUrl')
|
||||
? mapped.filter((p: any) => p.type !== 'video')
|
||||
: mapped
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load files', err)
|
||||
} finally {
|
||||
loadingGallery.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const confirmGallerySelect = () => {
|
||||
brand.value[gallerySelectTarget.value] = selectedPhotoUrl.value
|
||||
showGallerySelectModal.value = false
|
||||
message.success('已从照片墙选择并应用该文件')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfigs()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<h3 class="m-0 text-base font-760 text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-database-outline text-lg tone-accent"></span>
|
||||
数据库连接属性设置
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1">博主可以直接在这里修改服务端 PostgreSQL 连接属性,完成平滑的物理库重连迁移。</p>
|
||||
</div>
|
||||
<n-button
|
||||
secondary
|
||||
strong
|
||||
size="small"
|
||||
tag="a"
|
||||
:href="getBlogUrl('/writing/database-guide')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="archive-btn shrink-0"
|
||||
>
|
||||
<template #icon><span class="i-mdi-help-circle-outline"></span></template>
|
||||
查看配置文档
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-form label-placement="top" class="mt-5 space-y-4">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||
<n-form-item label="主机地址 (Host)" required>
|
||||
<n-input v-model:value="dbConfig.host" placeholder="如: localhost 或 127.0.0.1" />
|
||||
</n-form-item>
|
||||
<n-form-item label="端口号 (Port)" required>
|
||||
<n-input v-model:value="dbConfig.port" placeholder="如: 5432" />
|
||||
</n-form-item>
|
||||
<n-form-item label="数据库库名 (Database)" required>
|
||||
<n-input v-model:value="dbConfig.databaseName" placeholder="如: my_house" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="数据库账号用户名 (Username)" required>
|
||||
<n-input v-model:value="dbConfig.username" placeholder="如: postgres" />
|
||||
</n-form-item>
|
||||
<n-form-item label="数据库账号密码 (Password)" required>
|
||||
<n-input v-model:value="dbConfig.password" type="password" show-password-on="click" placeholder="输入对应数据库密码" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<div class="soft-panel p-3.5 bg-red-500/5 border border-red-500/10 rounded-2xl flex items-start gap-3">
|
||||
<span class="i-mdi-flash-outline text-red-500 mt-0.5 text-base"></span>
|
||||
<div>
|
||||
<p class="m-0 text-xs font-700 text-red-500">高危操作提示</p>
|
||||
<p class="m-0 mt-0.5 text-[11px] leading-relaxed text-red-500/70">
|
||||
更改数据库配置可能会导致服务端与当前数据库失去连接并发生自动重连。如果填写的账号或者主机密码错误,会导致整个系统中断无法服务。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-(--archive-border)/40 pt-4 mt-2 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
测试并更新数据库连接
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NInput, NButton } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
const getBlogUrl = (path: string) => {
|
||||
const protocol = window.location.protocol
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '127.0.0.1') {
|
||||
return `${protocol}//localhost:3000${path}`
|
||||
}
|
||||
if (hostname.startsWith('admin.')) {
|
||||
const mainDomain = hostname.replace('admin.', '')
|
||||
return `${protocol}//${mainDomain}${path}`
|
||||
}
|
||||
return `${protocol}//${hostname}${path}`
|
||||
}
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const dbConfig = ref({
|
||||
host: '',
|
||||
port: '',
|
||||
databaseName: '',
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
const fetchDbConfig = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('satoken')
|
||||
const response = await axios.get('http://localhost:8080/api/config/database', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
if (response.data && response.data.code === 200) {
|
||||
dbConfig.value = response.data.data || { host: '', port: '', databaseName: '', username: '', password: '' }
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch database configuration', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
const token = localStorage.getItem('satoken')
|
||||
try {
|
||||
const response = await axios.post('http://localhost:8080/api/config/database', dbConfig.value, {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success(response.data.msg || '数据库配置已成功保存')
|
||||
await fetchDbConfig()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '网络连接失败,数据库配置保存失败。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchDbConfig()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<h3 class="m-0 text-base font-760 text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-cloud-upload-outline text-lg tone-accent"></span>
|
||||
存储与图床配置
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1">配置博文、照片、日记和恋爱瞬间上传时的媒体文件存储图床。</p>
|
||||
</div>
|
||||
<n-button
|
||||
secondary
|
||||
strong
|
||||
size="small"
|
||||
tag="a"
|
||||
:href="getBlogUrl('/writing/config-guide')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="archive-btn shrink-0"
|
||||
>
|
||||
<template #icon><span class="i-mdi-help-circle-outline"></span></template>
|
||||
查看配置文档
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-form label-placement="top" class="mt-5 space-y-4">
|
||||
<n-form-item label="当前存储介质类型" required>
|
||||
<n-select v-model:value="formModel.storageType" :options="storageOptions" />
|
||||
</n-form-item>
|
||||
|
||||
<div class="soft-panel p-3.5 bg-(--archive-accent)/5 border border-(--archive-accent)/10 rounded-2xl flex items-start gap-3">
|
||||
<span class="i-mdi-information-outline tone-accent mt-0.5 text-base"></span>
|
||||
<div>
|
||||
<p class="m-0 text-xs font-700 text-(--archive-text)">{{ activeStorageLabel }}已激活</p>
|
||||
<p class="m-0 mt-0.5 text-[11px] leading-relaxed tone-muted">
|
||||
{{ storageOptions.find(o => o.value === formModel.storageType)?.desc }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Local Config (No fields, local is server disk) -->
|
||||
<div v-if="formModel.storageType === 'local'" class="soft-panel p-4 rounded-2xl bg-black/5 dark:bg-white/5 border border-dashed border-(--archive-border)/40 text-center">
|
||||
<span class="i-mdi-folder-home-outline text-3xl tone-faint block mx-auto mb-1"></span>
|
||||
<span class="text-xs tone-muted">本地存储无需配置额外参数。上传的文件将物理存放于服务端的 /uploads/ 目录下。</span>
|
||||
</div>
|
||||
|
||||
<!-- MinIO Config -->
|
||||
<div v-else-if="formModel.storageType === 'minio'" class="space-y-4 pt-2">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="MinIO Endpoint (API访问端点)" required>
|
||||
<n-input v-model:value="formModel.minio.endpoint" placeholder="如: http://127.0.0.1:9000" />
|
||||
</n-form-item>
|
||||
<n-form-item label="MinIO Bucket Name (存储桶名称)" required>
|
||||
<n-input v-model:value="formModel.minio.bucketName" placeholder="如: my-house" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="MinIO Access Key (用户名/ID)" required>
|
||||
<n-input v-model:value="formModel.minio.accessKey" placeholder="输入 MinIO 访问密钥 ID" />
|
||||
</n-form-item>
|
||||
<n-form-item label="MinIO Secret Key (密码/密文)" required>
|
||||
<n-input v-model:value="formModel.minio.secretKey" type="password" show-password-on="click" placeholder="输入 MinIO 安全访问密钥" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 七牛云 Config -->
|
||||
<div v-else-if="formModel.storageType === 'qiniu'" class="space-y-4 pt-2">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="七牛云 Access Key (公钥)" required>
|
||||
<n-input v-model:value="formModel.qiniu.accessKey" placeholder="输入七牛云账户 AccessKey" />
|
||||
</n-form-item>
|
||||
<n-form-item label="七牛云 Secret Key (私钥)" required>
|
||||
<n-input v-model:value="formModel.qiniu.secretKey" type="password" show-password-on="click" placeholder="输入七牛云账户 SecretKey" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="七牛云 Bucket Name (空间名称)" required>
|
||||
<n-input v-model:value="formModel.qiniu.bucketName" placeholder="如: myhouse-bucket" />
|
||||
</n-form-item>
|
||||
<n-form-item label="七牛云加速域名 (绑定外链CDN域名)" required>
|
||||
<n-input v-model:value="formModel.qiniu.domain" placeholder="如: http://qiniu.yourdomain.com" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-(--archive-border)/40 pt-4 mt-2 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
保存存储配置
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NSelect, NInput, NButton } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
const getBlogUrl = (path: string) => {
|
||||
const protocol = window.location.protocol
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '127.0.0.1') {
|
||||
return `${protocol}//localhost:3000${path}`
|
||||
}
|
||||
if (hostname.startsWith('admin.')) {
|
||||
const mainDomain = hostname.replace('admin.', '')
|
||||
return `${protocol}//${mainDomain}${path}`
|
||||
}
|
||||
return `${protocol}//${hostname}${path}`
|
||||
}
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const formModel = ref({
|
||||
storageType: 'local',
|
||||
minio: {
|
||||
endpoint: '',
|
||||
accessKey: '',
|
||||
secretKey: '',
|
||||
bucketName: ''
|
||||
},
|
||||
qiniu: {
|
||||
accessKey: '',
|
||||
secretKey: '',
|
||||
bucketName: '',
|
||||
domain: ''
|
||||
}
|
||||
})
|
||||
|
||||
const storageOptions = [
|
||||
{
|
||||
value: 'local',
|
||||
label: '本地服务器存储',
|
||||
desc: '零外部依赖,图片直接上传至后端服务器 uploads 目录中。'
|
||||
},
|
||||
{
|
||||
value: 'minio',
|
||||
label: 'MinIO 对象存储',
|
||||
desc: '适合本地搭建的私有 S3 存储,大文件与媒体库好去处。'
|
||||
},
|
||||
{
|
||||
value: 'qiniu',
|
||||
label: '七牛云 Kodo 图床',
|
||||
desc: '集成加速域名 CDN,上传极速,适合线上公网生产环境部署。'
|
||||
}
|
||||
]
|
||||
|
||||
const activeStorageLabel = computed(() => {
|
||||
const opt = storageOptions.find(o => o.value === formModel.value.storageType)
|
||||
return opt ? opt.label : ''
|
||||
})
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('satoken')
|
||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
const list = response.data.data || []
|
||||
const getValue = (key: string, def: string) => {
|
||||
const item = list.find((c: any) => c.configKey === key)
|
||||
return item ? item.configValue : def
|
||||
}
|
||||
|
||||
formModel.value.storageType = getValue('storage.type', 'local')
|
||||
formModel.value.minio.endpoint = getValue('storage.minio.endpoint', '')
|
||||
formModel.value.minio.accessKey = getValue('storage.minio.accessKey', '')
|
||||
formModel.value.minio.secretKey = getValue('storage.minio.secretKey', '')
|
||||
formModel.value.minio.bucketName = getValue('storage.minio.bucketName', '')
|
||||
|
||||
formModel.value.qiniu.accessKey = getValue('storage.qiniu.accessKey', '')
|
||||
formModel.value.qiniu.secretKey = getValue('storage.qiniu.secretKey', '')
|
||||
formModel.value.qiniu.bucketName = getValue('storage.qiniu.bucketName', '')
|
||||
formModel.value.qiniu.domain = getValue('storage.qiniu.domain', '')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch storage configs', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
const token = localStorage.getItem('satoken')
|
||||
|
||||
const payload = [
|
||||
{ configKey: 'storage.type', configValue: formModel.value.storageType, description: '存储方式: local, minio, qiniu' },
|
||||
{ configKey: 'storage.minio.endpoint', configValue: formModel.value.minio.endpoint, description: 'MinIO服务访问端点' },
|
||||
{ configKey: 'storage.minio.accessKey', configValue: formModel.value.minio.accessKey, description: 'MinIO Access Key' },
|
||||
{ configKey: 'storage.minio.secretKey', configValue: formModel.value.minio.secretKey, description: 'MinIO Secret Key' },
|
||||
{ configKey: 'storage.minio.bucketName', configValue: formModel.value.minio.bucketName, description: 'MinIO 存储空间桶名' },
|
||||
{ configKey: 'storage.qiniu.accessKey', configValue: formModel.value.qiniu.accessKey, description: '七牛云 Access Key' },
|
||||
{ configKey: 'storage.qiniu.secretKey', configValue: formModel.value.qiniu.secretKey, description: '七牛云 Secret Key' },
|
||||
{ configKey: 'storage.qiniu.bucketName', configValue: formModel.value.qiniu.bucketName, description: '七牛云 存储空间名' },
|
||||
{ configKey: 'storage.qiniu.domain', configValue: formModel.value.qiniu.domain, description: '七牛云加速域名' }
|
||||
]
|
||||
|
||||
try {
|
||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success('存储与图床配置已成功保存')
|
||||
await fetchConfigs()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '网络连接失败,配置保存失败。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfigs()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,592 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="m-0 text-base font-760 text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-palette-outline text-lg tone-accent"></span>
|
||||
自定义外观主题与配色系统
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1">深度定制博主的个人视觉形象(亮色与暗色模式的色彩体系、电影颗粒感及背景)。</p>
|
||||
</div>
|
||||
<n-button secondary size="small" type="warning" @click="handleResetDefaultTheme">
|
||||
重置为系统默认
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-form label-placement="top" class="mt-6 space-y-5">
|
||||
<div class="flex items-center justify-between py-2 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text)">激活自定义外观</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">开启后,前台渲染将物理覆盖默认配置,而强制使用博主下方的色彩定义。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="theme.enabled" />
|
||||
</div>
|
||||
|
||||
<div v-if="theme.enabled" class="space-y-6 pt-3">
|
||||
<!-- 设计师预设主题一键应用 -->
|
||||
<div class="p-4 bg-(--archive-border)/10 rounded-2xl border border-(--archive-border)/40">
|
||||
<p class="m-0 text-xs font-bold text-(--archive-text) mb-3 flex items-center gap-1.5 flex-wrap">
|
||||
<span class="i-mdi-palette-swatch-outline text-base tone-accent"></span>
|
||||
<span>设计师预设色彩主题 (UI/UX Calibrated Presets)</span>
|
||||
<span class="text-[10px] font-normal tone-muted ml-2 flex items-center gap-0.5">
|
||||
<span class="i-mdi-alert-circle-outline text-xs text-amber-500"></span>
|
||||
<span>建议使用系统配色,防止页面内容被遮挡</span>
|
||||
</span>
|
||||
</p>
|
||||
<div class="grid grid-cols-2 sm:grid-cols-4 md:grid-cols-7 gap-3">
|
||||
<div
|
||||
v-for="preset in themePresets"
|
||||
:key="preset.id"
|
||||
class="flex flex-col items-center p-2.5 rounded-xl border cursor-pointer transition-all hover:bg-black/5 dark:hover:bg-white/5 active:scale-98"
|
||||
:class="[
|
||||
isCurrentPreset(preset)
|
||||
? 'border-(--archive-accent) bg-(--archive-accent)/5 shadow-sm'
|
||||
: 'border-(--archive-border)/40 bg-white/30 dark:bg-white/5'
|
||||
]"
|
||||
@click="applyPreset(preset)"
|
||||
>
|
||||
<!-- 拼色指示器 -->
|
||||
<div class="w-12 h-6 rounded-full overflow-hidden flex border border-black/10 shadow-inner mb-2 shrink-0">
|
||||
<div class="w-1/4 h-full" :style="{ backgroundColor: preset.colors.accentColor }" title="亮色主调"></div>
|
||||
<div class="w-1/4 h-full" :style="{ backgroundColor: preset.colors.bgColor }" title="亮色背景"></div>
|
||||
<div class="w-1/4 h-full" :style="{ backgroundColor: preset.colors.darkAccentColor }" title="暗色主调"></div>
|
||||
<div class="w-1/4 h-full" :style="{ backgroundColor: preset.colors.darkBgColor }" title="暗色背景"></div>
|
||||
</div>
|
||||
<span class="text-[11px] font-700 text-(--archive-text)">{{ preset.name }}</span>
|
||||
<span class="text-[9px] tone-muted mt-0.5 text-center">{{ preset.desc }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 亮色配色体系 -->
|
||||
<div>
|
||||
<p class="m-0 text-xs font-bold border-b border-(--archive-border)/40 pb-2 mb-4 text-(--archive-text)">亮色模式配色定义 (Light Theme)</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="亮色主调色 (Accent Color)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.accentColor" placeholder="#D9865F" class="flex-1" />
|
||||
<input type="color" v-model="theme.accentColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-form-item label="亮色辅助柔和色 (Accent Soft Color)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.accentSoftColor" placeholder="#F1B894" class="flex-1" />
|
||||
<input type="color" v-model="theme.accentSoftColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mt-2">
|
||||
<n-form-item label="亮色背景主色 (Background Color)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.bgColor" placeholder="#F7F8F1" class="flex-1" />
|
||||
<input type="color" v-model="theme.bgColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-form-item label="亮色背景次色 (Soft Background)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.bgSoftColor" placeholder="#EAF0E5" class="flex-1" />
|
||||
<input type="color" v-model="theme.bgSoftColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 暗色配色体系 -->
|
||||
<div>
|
||||
<p class="m-0 text-xs font-bold border-b border-(--archive-border)/40 pb-2 mb-4 text-(--archive-text)">暗色模式配色定义 (Dark Theme)</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="暗色主调色 (Dark Accent Color)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.darkAccentColor" placeholder="#F1A77C" class="flex-1" />
|
||||
<input type="color" v-model="theme.darkAccentColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-form-item label="暗色辅助柔和色 (Dark Accent Soft)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.darkAccentSoftColor" placeholder="#F5C6A8" class="flex-1" />
|
||||
<input type="color" v-model="theme.darkAccentSoftColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mt-2">
|
||||
<n-form-item label="暗色背景主色 (Dark Background Color)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.darkBgColor" placeholder="#17211B" class="flex-1" />
|
||||
<input type="color" v-model="theme.darkBgColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-form-item label="暗色背景次色 (Dark Soft Background)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.darkBgSoftColor" placeholder="#203027" class="flex-1" />
|
||||
<input type="color" v-model="theme.darkBgSoftColor" class="w-10 h-8 rounded border" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全局噪点、氛围灯效与大图 -->
|
||||
<div>
|
||||
<p class="m-0 text-xs font-bold border-b border-(--archive-border)/40 pb-2 mb-4 text-(--archive-text)">质感微调与多媒体氛围 (Texture & Media)</p>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<n-form-item label="电影胶片噪点噪点不透明度 (%)">
|
||||
<n-input-number v-model:value="theme.grainOpacity" :min="0" :max="100" class="w-full" />
|
||||
</n-form-item>
|
||||
<div class="flex items-center justify-between py-2 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text)">霓虹氛围背景灯效 (Neon Glows)</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">是否在前台主页及列表渲染多层霓虹流动渐变光照。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="theme.glowsEnabled" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全局背景图片配置 -->
|
||||
<div class="grid grid-cols-1 gap-4 mt-4">
|
||||
<n-form-item label="自定义全局背景图片 URL (留空使用默认渐变)">
|
||||
<div class="flex gap-2 w-full">
|
||||
<n-input v-model:value="theme.bgImageUrl" placeholder="输入外部图片URL,或使用下方本地上传..." class="font-mono flex-1" clearable />
|
||||
<n-button secondary @click="openGallerySelect()">从照片墙选择</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2 mb-2">
|
||||
<n-upload
|
||||
action="http://localhost:8080/api/blogs/upload?type=theme"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
@finish="handleBgUploadFinish"
|
||||
@error="handleBgUploadError"
|
||||
>
|
||||
<n-button secondary size="small" type="primary">
|
||||
<template #icon><span class="i-mdi-upload"></span></template>
|
||||
本地上传背景图
|
||||
</n-button>
|
||||
</n-upload>
|
||||
<n-button v-if="theme.bgImageUrl" secondary size="small" type="error" @click="handleRemoveBgImage">
|
||||
恢复默认背景
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<div v-if="theme.bgImageUrl" class="grid grid-cols-1 sm:grid-cols-4 gap-4 p-4 soft-panel rounded-2xl bg-black/5 dark:bg-white/5 border border-(--archive-border)/40">
|
||||
<n-form-item label="展示样式 (Style)">
|
||||
<n-select v-model:value="theme.bgImageStyle" :options="[
|
||||
{ label: '拉伸平铺 (Cover)', value: 'cover' },
|
||||
{ label: '完整居中 (Contain)', value: 'contain' },
|
||||
{ label: '平铺瓦片 (Tile)', value: 'tile' }
|
||||
]" />
|
||||
</n-form-item>
|
||||
<n-form-item label="背景图毛玻璃模糊 (px)">
|
||||
<n-input-number v-model:value="theme.bgImageBlur" :min="0" :max="40" class="w-full" />
|
||||
</n-form-item>
|
||||
<n-form-item label="亮色模式透明度 (0-100)">
|
||||
<n-input-number v-model:value="theme.bgImageOpacity" :min="0" :max="100" class="w-full" />
|
||||
</n-form-item>
|
||||
<n-form-item label="暗色模式透明度 (0-100)">
|
||||
<n-input-number v-model:value="theme.darkBgImageOpacity" :min="0" :max="100" class="w-full" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 附加自定义 CSS 样式 -->
|
||||
<div class="grid grid-cols-1 gap-4 mt-6">
|
||||
<n-form-item label="前台附加自定义 CSS 代码 (用于深度重载或样式微调)">
|
||||
<n-input v-model:value="theme.customCss" type="textarea" :rows="5" placeholder="如: body { font-variant-numeric: tabular-nums; } .writing-card { border-radius: 12px !important; }" class="font-mono" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-(--archive-border)/40 pt-4 mt-2 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
应用主题外观配置
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
|
||||
<!-- 从照片墙图册选择弹窗 -->
|
||||
<n-modal
|
||||
v-model:show="showGallerySelectModal"
|
||||
preset="card"
|
||||
title="从相册选择背景图片"
|
||||
class="w-[95vw] max-w-[700px]"
|
||||
>
|
||||
<div v-if="loadingGallery" class="py-12 flex justify-center">
|
||||
<n-spin size="medium" />
|
||||
</div>
|
||||
<div v-else-if="galleryPhotos.length === 0" class="py-12 text-center">
|
||||
<span class="i-mdi-image-off-outline text-5xl tone-muted opacity-60"></span>
|
||||
<p class="text-xs tone-muted mt-2">您的相册库空空如也,请先在「照片墙」管理中添加照片。</p>
|
||||
</div>
|
||||
<div v-else class="space-y-4">
|
||||
<p class="text-xs tone-muted leading-relaxed">
|
||||
点击选择下方图册中的照片,点击「确认选择」后即可将其应用为背景。
|
||||
</p>
|
||||
|
||||
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 max-h-[50vh] overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="photo in galleryPhotos"
|
||||
:key="photo.id"
|
||||
class="group relative aspect-[3/2] rounded-xl overflow-hidden border transition-all cursor-pointer bg-black/5"
|
||||
:class="[
|
||||
selectedPhotoUrl === photo.src
|
||||
? 'border-(--archive-accent) ring-2 ring-(--archive-accent) ring-offset-2 dark:ring-offset-neutral-900'
|
||||
: 'border-(--archive-border)/40 hover:border-(--archive-accent)/60'
|
||||
]"
|
||||
@click="selectedPhotoUrl = photo.src"
|
||||
>
|
||||
<img :src="photo.src" :alt="photo.title" class="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105" />
|
||||
<div v-if="selectedPhotoUrl === photo.src" class="absolute inset-0 bg-[color-mix(in_srgb,var(--archive-accent)_15%,transparent)] flex items-center justify-center">
|
||||
<span class="i-mdi-check-circle text-2xl text-(--archive-accent)"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #action>
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<n-button size="small" round @click="showGallerySelectModal = false">取消</n-button>
|
||||
<n-button type="primary" size="small" round :disabled="!selectedPhotoUrl" @click="confirmGallerySelect">确认选择</n-button>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NInput, NInputNumber, NSwitch, NUpload, NButton, NModal, NSpin } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const defaultTheme = {
|
||||
enabled: false,
|
||||
accentColor: '#D9865F',
|
||||
accentSoftColor: '#F1B894',
|
||||
bgColor: '#F7F8F1',
|
||||
bgSoftColor: '#EAF0E5',
|
||||
darkAccentColor: '#F1A77C',
|
||||
darkAccentSoftColor: '#F5C6A8',
|
||||
darkBgColor: '#17211B',
|
||||
darkBgSoftColor: '#203027',
|
||||
grainOpacity: 3.8,
|
||||
glowsEnabled: false,
|
||||
bgImageUrl: '',
|
||||
bgImageStyle: 'cover',
|
||||
bgImageBlur: 0,
|
||||
bgImageOpacity: 10,
|
||||
darkBgImageOpacity: 5,
|
||||
customCss: ''
|
||||
}
|
||||
|
||||
const theme = ref(JSON.parse(JSON.stringify(defaultTheme)))
|
||||
|
||||
// 照片墙选择弹窗相关
|
||||
const showGallerySelectModal = ref(false)
|
||||
const loadingGallery = ref(false)
|
||||
const galleryPhotos = ref<any[]>([])
|
||||
const selectedPhotoUrl = ref('')
|
||||
|
||||
|
||||
const uploadHeaders = computed(() => ({
|
||||
satoken: localStorage.getItem('satoken') || ''
|
||||
}))
|
||||
|
||||
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('satoken')
|
||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
const list = response.data.data || []
|
||||
const getValue = (key: string, def: string) => {
|
||||
const item = list.find((c: any) => c.configKey === key)
|
||||
return item ? item.configValue : def
|
||||
}
|
||||
|
||||
theme.value.enabled = getValue('page.theme.enabled', 'false') === 'true'
|
||||
theme.value.accentColor = getValue('page.theme.accentColor', '#D9865F')
|
||||
theme.value.accentSoftColor = getValue('page.theme.accentSoftColor', '#F1B894')
|
||||
theme.value.bgColor = getValue('page.theme.bgColor', '#F7F8F1')
|
||||
theme.value.bgSoftColor = getValue('page.theme.bgSoftColor', '#EAF0E5')
|
||||
theme.value.darkAccentColor = getValue('page.theme.darkAccentColor', '#F1A77C')
|
||||
theme.value.darkAccentSoftColor = getValue('page.theme.darkAccentSoftColor', '#F5C6A8')
|
||||
theme.value.darkBgColor = getValue('page.theme.darkBgColor', '#17211B')
|
||||
theme.value.darkBgSoftColor = getValue('page.theme.darkBgSoftColor', '#203027')
|
||||
theme.value.grainOpacity = Number(getValue('page.theme.grainOpacity', '3.8'))
|
||||
theme.value.glowsEnabled = getValue('page.theme.glowsEnabled', 'false') === 'true'
|
||||
theme.value.bgImageUrl = getValue('page.theme.bgImageUrl', '')
|
||||
theme.value.bgImageStyle = getValue('page.theme.bgImageStyle', 'cover')
|
||||
theme.value.bgImageBlur = Number(getValue('page.theme.bgImageBlur', '0'))
|
||||
theme.value.bgImageOpacity = Number(getValue('page.theme.bgImageOpacity', '10'))
|
||||
theme.value.darkBgImageOpacity = Number(getValue('page.theme.darkBgImageOpacity', '5'))
|
||||
theme.value.customCss = getValue('page.theme.customCss', '')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load theme config', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
const token = localStorage.getItem('satoken')
|
||||
|
||||
const payload = [
|
||||
{ configKey: 'page.theme.enabled', configValue: String(theme.value.enabled), description: '是否启用系统自定义外观主题' },
|
||||
{ configKey: 'page.theme.accentColor', configValue: theme.value.accentColor, description: '自定义主题-亮色模式主色' },
|
||||
{ configKey: 'page.theme.accentSoftColor', configValue: theme.value.accentSoftColor, description: '自定义主题-亮色模式柔和主色' },
|
||||
{ configKey: 'page.theme.bgColor', configValue: theme.value.bgColor, description: '自定义主题-亮色模式背景色' },
|
||||
{ configKey: 'page.theme.bgSoftColor', configValue: theme.value.bgSoftColor, description: '自定义主题-亮色模式次级背景色' },
|
||||
{ configKey: 'page.theme.darkAccentColor', configValue: theme.value.darkAccentColor, description: '自定义主题-暗色模式主色' },
|
||||
{ configKey: 'page.theme.darkAccentSoftColor', configValue: theme.value.darkAccentSoftColor, description: '自定义主题-暗色模式柔和主色' },
|
||||
{ configKey: 'page.theme.darkBgColor', configValue: theme.value.darkBgColor, description: '自定义主题-暗色模式背景色' },
|
||||
{ configKey: 'page.theme.darkBgSoftColor', configValue: theme.value.darkBgSoftColor, description: '自定义主题-暗色模式次级背景色' },
|
||||
{ configKey: 'page.theme.grainOpacity', configValue: String(theme.value.grainOpacity), description: '自定义主题-电影噪点不透明度(0-100)' },
|
||||
{ configKey: 'page.theme.glowsEnabled', configValue: String(theme.value.glowsEnabled), description: '自定义主题-是否开启霓虹背景灯效' },
|
||||
{ configKey: 'page.theme.bgImageUrl', configValue: theme.value.bgImageUrl, description: '自定义主题-全局背景图片URL' },
|
||||
{ configKey: 'page.theme.bgImageStyle', configValue: theme.value.bgImageStyle || 'cover', description: '自定义主题-背景图展示样式(cover/contain/tile)' },
|
||||
{ configKey: 'page.theme.bgImageBlur', configValue: String(theme.value.bgImageBlur || 0), description: '自定义主题-背景图模糊度(0-40px)' },
|
||||
{ configKey: 'page.theme.bgImageOpacity', configValue: String(theme.value.bgImageOpacity || 10), description: '自定义主题-亮色模式背景图透明度(0-100)' },
|
||||
{ configKey: 'page.theme.darkBgImageOpacity', configValue: String(theme.value.darkBgImageOpacity || 5), description: '自定义主题-暗色模式背景图透明度(0-100)' },
|
||||
{ configKey: 'page.theme.customCss', configValue: theme.value.customCss, description: '自定义主题-附加自定义CSS样式代码' }
|
||||
]
|
||||
|
||||
try {
|
||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success('外观色彩配置应用成功,刷新后将同步展现!')
|
||||
window.dispatchEvent(new CustomEvent('atlas-config-changed'))
|
||||
await fetchConfigs()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '网络连接失败,外观色彩配置应用失败。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleBgUploadFinish = ({ event }: any) => {
|
||||
try {
|
||||
const responseText = (event?.target as any)?.response
|
||||
if (responseText) {
|
||||
const res = JSON.parse(responseText)
|
||||
if (res && res.code === 200 && res.data) {
|
||||
theme.value.bgImageUrl = res.data
|
||||
message.success('自定义背景图片上传成功 🖼️')
|
||||
} else {
|
||||
throw new Error(res?.msg || '上传接口返回错误')
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(`背景图上传失败: ${err.message || '解析错误'}`)
|
||||
}
|
||||
}
|
||||
|
||||
const handleBgUploadError = () => {
|
||||
message.error('图片上传失败,请检查网络或后端接口是否在线 ⚠️')
|
||||
}
|
||||
|
||||
const handleRemoveBgImage = () => {
|
||||
theme.value.bgImageUrl = ''
|
||||
message.success('已恢复默认背景')
|
||||
}
|
||||
|
||||
const openGallerySelect = async () => {
|
||||
showGallerySelectModal.value = true
|
||||
loadingGallery.value = true
|
||||
selectedPhotoUrl.value = theme.value.bgImageUrl || ''
|
||||
const token = localStorage.getItem('satoken')
|
||||
try {
|
||||
const response = await axios.get('http://localhost:8080/api/gallery/list', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
if (response.data && response.data.code === 200) {
|
||||
galleryPhotos.value = (response.data.data || []).filter((p: any) => p.type !== 'video')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load gallery photos', err)
|
||||
} finally {
|
||||
loadingGallery.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const confirmGallerySelect = () => {
|
||||
theme.value.bgImageUrl = selectedPhotoUrl.value
|
||||
showGallerySelectModal.value = false
|
||||
message.success('已从照片墙选中并应用背景')
|
||||
}
|
||||
|
||||
const handleResetDefaultTheme = () => {
|
||||
theme.value = JSON.parse(JSON.stringify(defaultTheme))
|
||||
message.success('已重置为系统默认外观主题,请记得点击下方保存')
|
||||
}
|
||||
|
||||
interface PresetColors {
|
||||
accentColor: string
|
||||
accentSoftColor: string
|
||||
bgColor: string
|
||||
bgSoftColor: string
|
||||
darkAccentColor: string
|
||||
darkAccentSoftColor: string
|
||||
darkBgColor: string
|
||||
darkBgSoftColor: string
|
||||
}
|
||||
|
||||
interface ThemePreset {
|
||||
id: string
|
||||
name: string
|
||||
desc: string
|
||||
colors: PresetColors
|
||||
}
|
||||
|
||||
const themePresets: ThemePreset[] = [
|
||||
{
|
||||
id: 'amber',
|
||||
name: '琥珀橙',
|
||||
desc: '温暖秋日默认',
|
||||
colors: {
|
||||
accentColor: '#D9865F',
|
||||
accentSoftColor: '#F1B894',
|
||||
bgColor: '#F7F8F1',
|
||||
bgSoftColor: '#EAF0E5',
|
||||
darkAccentColor: '#F1A77C',
|
||||
darkAccentSoftColor: '#F5C6A8',
|
||||
darkBgColor: '#17211B',
|
||||
darkBgSoftColor: '#203027'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'matcha',
|
||||
name: '抹茶绿',
|
||||
desc: '清晨森系治愈',
|
||||
colors: {
|
||||
accentColor: '#4A7758',
|
||||
accentSoftColor: '#A3C1AD',
|
||||
bgColor: '#F6F8F5',
|
||||
bgSoftColor: '#EDF1EB',
|
||||
darkAccentColor: '#93C5A8',
|
||||
darkAccentSoftColor: '#6E9C80',
|
||||
darkBgColor: '#121A15',
|
||||
darkBgSoftColor: '#1B261F'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'lavender',
|
||||
name: '忧郁紫',
|
||||
desc: '落日薰衣草',
|
||||
colors: {
|
||||
accentColor: '#635170',
|
||||
accentSoftColor: '#C5B4C9',
|
||||
bgColor: '#F8F6F9',
|
||||
bgSoftColor: '#EFEBF2',
|
||||
darkAccentColor: '#C3B0CD',
|
||||
darkAccentSoftColor: '#A890B5',
|
||||
darkBgColor: '#161219',
|
||||
darkBgSoftColor: '#201A24'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'foggy',
|
||||
name: '雾霾蓝',
|
||||
desc: '冰川冷湖现代',
|
||||
colors: {
|
||||
accentColor: '#467285',
|
||||
accentSoftColor: '#A3C6D3',
|
||||
bgColor: '#F4F7F9',
|
||||
bgSoftColor: '#E8EEF1',
|
||||
darkAccentColor: '#82B2C6',
|
||||
darkAccentSoftColor: '#5C899E',
|
||||
darkBgColor: '#11161B',
|
||||
darkBgSoftColor: '#1B222A'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'sakura',
|
||||
name: '樱花粉',
|
||||
desc: '春雨初樱浪漫',
|
||||
colors: {
|
||||
accentColor: '#A65B69',
|
||||
accentSoftColor: '#ECC3C9',
|
||||
bgColor: '#FCF5F6',
|
||||
bgSoftColor: '#F7EAEB',
|
||||
darkAccentColor: '#E8A2AE',
|
||||
darkAccentSoftColor: '#D18491',
|
||||
darkBgColor: '#1B1214',
|
||||
darkBgSoftColor: '#261A1D'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'druid',
|
||||
name: '德鲁伊红',
|
||||
desc: '神秘赤红泥土',
|
||||
colors: {
|
||||
accentColor: '#8C3B32',
|
||||
accentSoftColor: '#D98A82',
|
||||
bgColor: '#F9F5F4',
|
||||
bgSoftColor: '#F1E6E4',
|
||||
darkAccentColor: '#E58E84',
|
||||
darkAccentSoftColor: '#C3766D',
|
||||
darkBgColor: '#1C1211',
|
||||
darkBgSoftColor: '#261A19'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'camel',
|
||||
name: '旷野驼',
|
||||
desc: '落叶橡木温暖',
|
||||
colors: {
|
||||
accentColor: '#876445',
|
||||
accentSoftColor: '#CA9B7C',
|
||||
bgColor: '#F7F5F0',
|
||||
bgSoftColor: '#EFECE3',
|
||||
darkAccentColor: '#D9B48F',
|
||||
darkAccentSoftColor: '#B89370',
|
||||
darkBgColor: '#1A1612',
|
||||
darkBgSoftColor: '#251F1A'
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const applyPreset = (preset: ThemePreset) => {
|
||||
theme.value.accentColor = preset.colors.accentColor
|
||||
theme.value.accentSoftColor = preset.colors.accentSoftColor
|
||||
theme.value.bgColor = preset.colors.bgColor
|
||||
theme.value.bgSoftColor = preset.colors.bgSoftColor
|
||||
theme.value.darkAccentColor = preset.colors.darkAccentColor
|
||||
theme.value.darkAccentSoftColor = preset.colors.darkAccentSoftColor
|
||||
theme.value.darkBgColor = preset.colors.darkBgColor
|
||||
theme.value.darkBgSoftColor = preset.colors.darkBgSoftColor
|
||||
message.success(`已应用“${preset.name}”主题配色,点击底部应用生效 ✨`)
|
||||
}
|
||||
|
||||
const isCurrentPreset = (preset: ThemePreset) => {
|
||||
if (!theme.value.accentColor) return false
|
||||
return theme.value.accentColor.toLowerCase() === preset.colors.accentColor.toLowerCase() &&
|
||||
theme.value.accentSoftColor.toLowerCase() === preset.colors.accentSoftColor.toLowerCase() &&
|
||||
theme.value.bgColor.toLowerCase() === preset.colors.bgColor.toLowerCase() &&
|
||||
theme.value.bgSoftColor.toLowerCase() === preset.colors.bgSoftColor.toLowerCase() &&
|
||||
theme.value.darkAccentColor.toLowerCase() === preset.colors.darkAccentColor.toLowerCase() &&
|
||||
theme.value.darkAccentSoftColor.toLowerCase() === preset.colors.darkAccentSoftColor.toLowerCase() &&
|
||||
theme.value.darkBgColor.toLowerCase() === preset.colors.darkBgColor.toLowerCase() &&
|
||||
theme.value.darkBgSoftColor.toLowerCase() === preset.colors.darkBgSoftColor.toLowerCase()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfigs()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="archive-card p-5 sm:p-6 bg-(--archive-bg-card) border border-(--archive-border) rounded-2xl">
|
||||
<h3 class="m-0 text-base font-760 text-(--archive-text) flex items-center gap-2">
|
||||
<span class="i-mdi-view-dashboard-outline text-lg tone-accent"></span>
|
||||
前台入口与页面可见性配置
|
||||
</h3>
|
||||
<p class="tone-muted text-xs mt-1">控制前台主导航上恋爱各个业务子板块(如“恋爱瞬间”、“岁月信件”、“目前状态”等)入口的展示开关。</p>
|
||||
|
||||
<n-form label-placement="left" class="mt-6 space-y-6 max-w-4xl">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-2">
|
||||
<!-- 1. 恋爱纪实 -->
|
||||
<div class="flex items-center justify-between py-2.5 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-heart-pulse tone-accent"></span> 恋爱纪实 (Love Diary)
|
||||
</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">控制恋爱瞬间、百事打卡清单、恋爱日记前台主导航可见性。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="page.loveEnable" />
|
||||
</div>
|
||||
|
||||
<!-- 2. 岁月信件 -->
|
||||
<div class="flex items-center justify-between py-2.5 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-email-outline tone-accent"></span> 岁月信件 (Letters)
|
||||
</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">控制前台是否能够进入“岁月信件与时光胶囊”密码信箱界面。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="page.letterEnable" />
|
||||
</div>
|
||||
|
||||
<!-- 3. 此时时刻 -->
|
||||
<div class="flex items-center justify-between py-2.5 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-flash-outline tone-accent"></span> 此时时刻 (Now Page)
|
||||
</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">是否展示博主个人当前专注状态、目前心境及听歌阅读看板。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="page.nowEnable" />
|
||||
</div>
|
||||
|
||||
<!-- 4. 岁月足迹 -->
|
||||
<div class="flex items-center justify-between py-2.5 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-earth tone-accent"></span> 岁月足迹 (Footprints)
|
||||
</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">控制前台高德/OSM地图的影像足迹、旅行航迹页面入口。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="page.footprintsEnable" />
|
||||
</div>
|
||||
|
||||
<!-- 5. 关于作者 -->
|
||||
<div class="flex items-center justify-between py-2.5 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-account-box-outline tone-accent"></span> 关于作者 (About Author)
|
||||
</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">控制博主个人成长时间线、心路历程、装备与技能树页面入口。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="page.aboutEnable" />
|
||||
</div>
|
||||
|
||||
<!-- 6. 鱼塘反馈 -->
|
||||
<div class="flex items-center justify-between py-2.5 border-b border-(--archive-border)/40">
|
||||
<div>
|
||||
<p class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-fish tone-accent"></span> 鱼塘反馈 (Pond Feedback)
|
||||
</p>
|
||||
<p class="m-0 mt-0.5 text-xs tone-muted">控制前台倾听倾诉、留言板及用户反馈页面入口。</p>
|
||||
</div>
|
||||
<n-switch v-model:value="page.pondEnable" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 安全访问口令配置 -->
|
||||
<div class="pt-6 border-t border-(--archive-border)/40 space-y-4">
|
||||
<h4 class="m-0 text-sm font-700 text-(--archive-text) flex items-center gap-1.5">
|
||||
<span class="i-mdi-lock-open-outline tone-accent"></span>
|
||||
安全访问与私密档案口令 (Access Passcode)
|
||||
</h4>
|
||||
<p class="m-0 text-xs tone-muted">设置前台解锁全站随笔加密区、私密恋爱归档所使用的全局安全访问口令(默认:2026)。</p>
|
||||
<n-form-item label="全局解密口令" :show-feedback="false">
|
||||
<n-input
|
||||
v-model:value="passcode"
|
||||
type="password"
|
||||
show-password-on="mousedown"
|
||||
placeholder="请输入安全访问口令,如 2026"
|
||||
class="archive-input max-w-xs font-mono"
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<div class="pt-4 flex justify-end">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">
|
||||
<template #icon><span class="i-mdi-content-save-outline"></span></template>
|
||||
应用可见性配置
|
||||
</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useMessage, NForm, NSwitch, NButton, NInput, NFormItem } from 'naive-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
const message = useMessage()
|
||||
const saving = ref(false)
|
||||
|
||||
const page = ref({
|
||||
loveEnable: true,
|
||||
letterEnable: true,
|
||||
nowEnable: true,
|
||||
aboutEnable: true,
|
||||
footprintsEnable: true,
|
||||
pondEnable: true
|
||||
})
|
||||
|
||||
const passcode = ref('2026')
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('satoken')
|
||||
const response = await axios.get('http://localhost:8080/api/config/list', {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
const list = response.data.data || []
|
||||
const getValue = (key: string, def: string) => {
|
||||
const item = list.find((c: any) => c.configKey === key)
|
||||
return item ? item.configValue : def
|
||||
}
|
||||
|
||||
page.value.loveEnable = getValue('page.love.enable', 'true') === 'true'
|
||||
page.value.letterEnable = getValue('page.letter.enable', 'true') === 'true'
|
||||
page.value.nowEnable = getValue('page.now.enable', 'true') === 'true'
|
||||
page.value.aboutEnable = getValue('page.about.enable', 'true') === 'true'
|
||||
page.value.footprintsEnable = getValue('page.footprints.enable', 'true') === 'true'
|
||||
page.value.pondEnable = getValue('page.pond.enable', 'true') === 'true'
|
||||
passcode.value = getValue('site.access.passcode', '2026')
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load visibility configs', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
saving.value = true
|
||||
const token = localStorage.getItem('satoken')
|
||||
|
||||
const payload = [
|
||||
{ configKey: 'page.love.enable', configValue: String(page.value.loveEnable), description: '是否开启“恋爱纪实”页面及导航入口' },
|
||||
{ configKey: 'page.letter.enable', configValue: String(page.value.letterEnable), description: '是否开启“岁月信件”页面及导航入口' },
|
||||
{ configKey: 'page.now.enable', configValue: String(page.value.nowEnable), description: '是否开启“目前状态”页面及导航入口' },
|
||||
{ configKey: 'page.about.enable', configValue: String(page.value.aboutEnable), description: '是否开启“关于作者”页面及导航入口' },
|
||||
{ configKey: 'page.footprints.enable', configValue: String(page.value.footprintsEnable), description: '是否开启“岁月足迹”页面及导航入口' },
|
||||
{ configKey: 'page.pond.enable', configValue: String(page.value.pondEnable), description: '是否开启“鱼塘反馈”页面及导航入口' },
|
||||
{ configKey: 'site.access.passcode', configValue: String(passcode.value), description: '全站随笔及恋爱私密档案全局访问口令' }
|
||||
]
|
||||
|
||||
try {
|
||||
const response = await axios.post('http://localhost:8080/api/config/update-batch', payload, {
|
||||
headers: { satoken: token }
|
||||
})
|
||||
|
||||
if (response.data && response.data.code === 200) {
|
||||
message.success('可见性配置已成功保存')
|
||||
await fetchConfigs()
|
||||
} else {
|
||||
throw new Error(response.data?.msg || '保存失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
message.error(err.message || '网络连接失败,配置保存失败。')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfigs()
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user