- 后台全面引入 Naive UI 组件库,统一 UI 规范 - 前台 usePublicApi 切换到 API 调用(GET /api/content/[key]) - 前后台数据源统一(site_content 表) - 产品线统一管理(tour/camp/course 三套编辑器) - 产品数据归一化(itinerary/faq/pricing 格式统一) - 表单提交 API 改写入 submissions 表 - 新增 submissions 标记已读 API - site-content PUT 支持 upsert - 修复前台 bug(stories 路由冲突、占位符警告、selector breadcrumb) - 消除 PageHero 类型警告(useSEO reactive 修复) - 25 个前台页面全部 HTTP 200,展示效果不变 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 行
2.0 KiB
Vue
64 行
2.0 KiB
Vue
<template>
|
|
<div style="max-width: 1100px">
|
|
<n-space justify="space-between" align="center" style="margin-bottom: 20px">
|
|
<div>
|
|
<h1 style="margin: 0 0 4px; font-size: 20px; font-weight: 600; color: #111827">图片配置</h1>
|
|
<p style="margin: 0; font-size: 13px; color: #9ca3af">管理网站各处使用的图片资源</p>
|
|
</div>
|
|
<n-button type="primary" :loading="saving" @click="save">保存</n-button>
|
|
</n-space>
|
|
|
|
<n-spin :show="!loaded">
|
|
<n-space vertical :size="16">
|
|
<n-card v-for="(group, groupKey) in data" :key="groupKey" :title="groupLabels[groupKey] || groupKey">
|
|
<n-grid :cols="3" :x-gap="16" :y-gap="16">
|
|
<n-gi v-for="(val, imgKey) in group" :key="imgKey">
|
|
<div>
|
|
<div style="font-size: 12px; color: #6b7280; margin-bottom: 6px; font-weight: 500">{{ imgKey }}</div>
|
|
<AdminImageUpload v-model="data[groupKey][imgKey]" />
|
|
</div>
|
|
</n-gi>
|
|
</n-grid>
|
|
</n-card>
|
|
</n-space>
|
|
</n-spin>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { NButton, NCard, NSpace, NSpin, NGrid, NGi } from 'naive-ui'
|
|
import { useMessage } from 'naive-ui'
|
|
|
|
definePageMeta({ layout: 'admin', middleware: 'admin' })
|
|
const { adminFetch } = useAdmin()
|
|
const message = useMessage()
|
|
const data = ref({})
|
|
const loaded = ref(false)
|
|
const saving = ref(false)
|
|
|
|
const groupLabels = {
|
|
logo: 'Logo', hero: '首页横幅', brandStory: '品牌故事',
|
|
mascot: '吉祥物', team: '团队', xiaohongshu: '小红书', summerCamp: '夏令营',
|
|
}
|
|
|
|
async function load() {
|
|
const res = await adminFetch('/api/admin/site-content?key=images')
|
|
data.value = res.data
|
|
loaded.value = true
|
|
}
|
|
|
|
async function save() {
|
|
saving.value = true
|
|
try {
|
|
await adminFetch('/api/admin/site-content', { method: 'PUT', body: { key: 'images', data: data.value } })
|
|
message.success('已保存')
|
|
} catch {
|
|
message.error('保存失败')
|
|
} finally {
|
|
saving.value = false
|
|
}
|
|
}
|
|
|
|
onMounted(load)
|
|
</script>
|