UNPKG

rsshub

Version:
50 lines (49 loc) 1.84 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; //#region lib/routes/qq/txc/post.ts const route = { path: "/txc/post/:project", categories: ["program-update"], example: "/qq/txc/post/28564", parameters: { project: "产品 ID" }, name: "兔小巢新帖", maintainers: ["Qixingchen"], handler, url: "txc.qq.com" }; async function handler(ctx) { const { project } = ctx.req.param(); const link = `https://support.qq.com/products/${project}`; const info = await cache_default.tryGet(`qq:txc:info:${project}`, async () => { const { data } = await rofetch(`https://support.qq.com/api/v1/${project}/products/info`, { headers: { Referer: link } }); return data; }); const { data } = await rofetch(`https://support.qq.com/api/v2/${project}/posts/label/show`); return { title: `${info.product_name} 的兔小巢新帖`, link, image: info.logo, item: Object.values(data).map((item) => { let title = `${item.nick_name} 的吐槽`; let description = item.content; if (item.type === 3) { const content = JSON.parse(item.content); title = content.title; description = [content.content, content.solution].filter(Boolean).join("<br>"); } else if (item.type === 4) { const content = JSON.parse(item.content); title = `版本更新 ${content.version}`.trim(); description = JSON.parse(content.content).map((section) => (section.title ? `<h3>${section.title}</h3>` : "") + section.detail).join(""); } return { title, description: description + item.images.map((image) => `<img src="${image.original_url}">`).join(""), pubDate: parseDate(item.created_at_timestamp, "X"), link: `${link}/post/${item.id}` }; }) }; } //#endregion export { route };