Mimingguang ee078b61bc feat: 后台管理系统完整重构 + 前后台数据联通
- 后台全面引入 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>
2026-03-24 17:48:02 +08:00

82 行
3.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">SEO 配置</h1>
<p style="margin: 0; font-size: 13px; color: #9ca3af">管理各页面的 SEO 标题描述关键词</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="(seo, pageKey) in data.pages" :key="pageKey">
<template #header>
<n-space align="center" :size="8">
<span>{{ pageLabels[pageKey] || pageKey }}</span>
<n-tag size="small" :bordered="false" style="font-size: 11px; color: #aaa; background: #f0f0f0">{{ pageKey }}</n-tag>
</n-space>
</template>
<n-form label-placement="top">
<n-form-item label="Title">
<n-input v-model:value="seo.title" />
</n-form-item>
<n-form-item label="H1">
<n-input v-model:value="seo.h1" />
</n-form-item>
<n-form-item label="Description">
<n-input v-model:value="seo.description" type="textarea" :rows="2" />
</n-form-item>
<n-form-item label="Keywords">
<n-input v-model:value="seo.keywords" placeholder="逗号分隔" />
</n-form-item>
<n-form-item label="OG Image">
<AdminImageUpload v-model="seo.ogImage" />
</n-form-item>
</n-form>
</n-card>
</n-space>
</n-spin>
</div>
</template>
<script setup>
import { NButton, NCard, NSpace, NInput, NForm, NFormItem, NSpin, NTag } from 'naive-ui'
import { useMessage } from 'naive-ui'
definePageMeta({ layout: 'admin', middleware: 'admin' })
const { adminFetch } = useAdmin()
const message = useMessage()
const data = ref({ pages: {} })
const loaded = ref(false)
const saving = ref(false)
const pageLabels = {
home: '首页', products: '产品页', 'summer-camp': '夏令营', 'winter-camp': '冬令营',
destinations: '目的地', guides: '出行指南', calendar: '旅行日历', faq: '常见问答',
reviews: '客户评价', gallery: '旅拍', about: '关于我们', contact: '联系我们',
news: '最新动态', qualifications: '资质荣誉', blog: '博客', pricing: '价格',
customize: '定制', selector: '产品选择器', stories: '客户故事', xiaohongshu: '小红书',
}
async function load() {
const res = await adminFetch('/api/admin/site-content?key=seo')
data.value = res.data
loaded.value = true
}
async function save() {
saving.value = true
try {
await adminFetch('/api/admin/site-content', { method: 'PUT', body: { key: 'seo', data: data.value } })
message.success('已保存')
} catch (e) {
message.error('保存失败')
} finally {
saving.value = false
}
}
onMounted(load)
</script>