feat: 收官补齐全部未实现功能
- 账号体系:修改密码(/account + PATCH /api/auth/password)、自助删除账号 (DELETE /api/auth/me)、订阅退订(token + /unsubscribe 页) - 前台/SEO:RSS 订阅 /feed.xml、作品详情分享、canonical URL、 文章 Article JSON-LD、品牌化错误页(i18n) - 后台增强:图片管理 /admin/uploads、操作审计日志 /admin/audit(含清空)、 联系消息已读标记、评论列表分页 - 工程:vitest 测试(密码哈希/内容校验器/种子完整性,12 例)+ pnpm test - DB 迁移:contacts.read、subscribers.token、audit_logs(老库 ALTER 兼容) - 密码逻辑抽为 server/utils/password.ts 供测试
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { getConfig } from '../utils/config'
|
||||
import { listArticles } from '../utils/content'
|
||||
|
||||
const escapeXml = (s: string) =>
|
||||
String(s ?? '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
|
||||
/**
|
||||
* RSS 2.0 订阅源 /feed.xml(动态全部已发布)
|
||||
*/
|
||||
export default defineEventHandler(() => {
|
||||
const { siteUrl } = getConfig()
|
||||
const articles = listArticles({ publishedOnly: true })
|
||||
|
||||
const items = articles
|
||||
.map((a) => {
|
||||
const title = a.titleZh || a.titleEn
|
||||
const desc = a.excerptZh || a.excerptEn
|
||||
const link = `${siteUrl}/news/${a.slug}`
|
||||
const date = a.date ? new Date(`${a.date}T00:00:00Z`).toUTCString() : new Date().toUTCString()
|
||||
return [
|
||||
' <item>',
|
||||
` <title>${escapeXml(title)}</title>`,
|
||||
` <link>${link}</link>`,
|
||||
` <guid isPermaLink="true">${link}</guid>`,
|
||||
` <description>${escapeXml(desc)}</description>`,
|
||||
` <pubDate>${date}</pubDate>`,
|
||||
' </item>',
|
||||
].join('\n')
|
||||
})
|
||||
.join('\n')
|
||||
|
||||
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>ArcticNewOne</title>
|
||||
<link>${siteUrl}</link>
|
||||
<description>北极新一工作室的最新动态与洞察</description>
|
||||
<language>zh-cn</language>
|
||||
<atom:link href="${siteUrl}/feed.xml" rel="self" type="application/rss+xml"/>
|
||||
${items}
|
||||
</channel>
|
||||
</rss>`
|
||||
|
||||
return new Response(xml, {
|
||||
headers: { 'Content-Type': 'application/rss+xml; charset=utf-8' },
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user