UNPKG

rsshub

Version:
77 lines (75 loc) 2.57 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { a as webBaseUrl, i as sign, n as getPost, r as phoneBaseUrl, t as generateNonce } from "./utils-DyDKLcNs.mjs"; //#region lib/routes/dxy/board.ts const route = { path: "/bbs/board/:boardId", categories: ["bbs"], example: "/dxy/bbs/board/46", parameters: { specialId: "板块 ID,可在对应板块页 URL 中找到" }, name: "板块", maintainers: ["TonyRL"], radar: [{ source: ["www.dxy.cn/bbs/newweb/pc/category/:boardIdId"], target: "/bbs/board/:boardIdId" }, { source: ["3g.dxy.cn/bbs/board/:boardIdId"], target: "/bbs/board/:boardIdId" }], handler }; async function handler(ctx) { const { boardId } = ctx.req.param(); const { limit = "20" } = ctx.req.query(); const boardDetail = await cache_default.tryGet(`dxy:board:detail:${boardId}`, async () => { const detailParams = { boardId, timestamp: Date.now(), noncestr: generateNonce(8, "number") }; const detail = await ofetch_default(`${phoneBaseUrl}/bbsapi/bbs/board/detail`, { query: { ...detailParams, sign: sign(detailParams) } }); if (detail.code !== "success") throw new Error(detail.message); return detail.data; }); const list = (await cache_default.tryGet(`dxy:board:list:${boardId}`, async () => { const listParams = { boardId, postType: "0", orderType: "1", pageNum: "1", pageSize: limit, timestamp: Date.now(), noncestr: generateNonce(8, "number") }; const recommendList = await ofetch_default(`${phoneBaseUrl}/bbsapi/bbs/board/post/list`, { query: { ...listParams, sign: sign(listParams) } }); if (recommendList.code !== "success") throw new Error(recommendList.message); return recommendList.data; }, config.cache.routeExpire, false)).result.map((item) => ({ title: item.subject, author: item.postUser.nickname, category: [boardDetail.title], link: `${webBaseUrl}/bbs/newweb/pc/post/${item.postId}`, postId: item.postId })); const items = await Promise.all(list.map((item) => getPost(item, cache_default.tryGet))); return { title: boardDetail.title, description: `${boardDetail.postCount} 內容 ${boardDetail.followCount} 关注`, link: `${webBaseUrl}/bbs/newweb/pc/category/${boardId}`, image: boardDetail.boardAvatar, item: items }; } //#endregion export { route };