- 后台全面引入 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>
34 行
1.3 KiB
JavaScript
34 行
1.3 KiB
JavaScript
import { eq } from 'drizzle-orm'
|
|
import { useDB, schema } from '../../../utils/db.js'
|
|
import { requireAdmin } from '../../../utils/auth.js'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
requireAdmin(event)
|
|
|
|
const id = Number(getRouterParam(event, 'id'))
|
|
const body = await readBody(event)
|
|
|
|
const db = useDB()
|
|
const updateData = { updatedAt: new Date().toISOString() }
|
|
|
|
if (body.title !== undefined) updateData.title = body.title
|
|
if (body.slug !== undefined) updateData.slug = body.slug
|
|
if (body.summary !== undefined) updateData.summary = body.summary
|
|
if (body.content !== undefined) updateData.content = body.content
|
|
if (body.category !== undefined) updateData.category = body.category
|
|
if (body.coverImage !== undefined) updateData.coverImage = body.coverImage
|
|
if (body.author !== undefined) updateData.author = body.author
|
|
if (body.tags !== undefined) updateData.tags = JSON.stringify(body.tags)
|
|
if (body.seoTitle !== undefined) updateData.seoTitle = body.seoTitle
|
|
if (body.seoDesc !== undefined) updateData.seoDesc = body.seoDesc
|
|
if (body.seoKeywords !== undefined) updateData.seoKeywords = body.seoKeywords
|
|
if (body.published !== undefined) updateData.published = body.published ? 1 : 0
|
|
|
|
db.update(schema.articles)
|
|
.set(updateData)
|
|
.where(eq(schema.articles.id, id))
|
|
.run()
|
|
|
|
return { success: true }
|
|
})
|