UNPKG

rsshub

Version:
103 lines (102 loc) 3.62 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import dayjs from "dayjs"; import { jsx, jsxs } from "hono/jsx/jsx-runtime"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/wuzhongmuseum/namespace.ts const namespace = { name: "Museum of Wu", url: "www.wuzhongmuseum.com", zh: { name: "吴文化博物馆" } }; //#endregion //#region lib/routes/wuzhongmuseum/exhibition.tsx const callCloudApi = async (path) => { const res = await rofetch("", { baseURL: "https://tcb-api.tencentcloudapi.com/web?env=wzmuse-4gcvvt77cf4e3c3e", method: "POST", headers: { "Content-Type": "application/json;charset=UTF-8", Origin: "https://www.wuzhongmuseum.com", Referer: "https://www.wuzhongmuseum.com/" }, body: { action: "functions.invokeFunction", dataVersion: "2020-01-10", env: "wzmuse-4gcvvt77cf4e3c3e", function_name: "portal-api", request_data: JSON.stringify({ httpMethod: "GET", path: `/v1${path}`, headers: { "wzmuseum-dlj-portal-id": "d6b23bdd639acd7d0018a893072234ab" } }) } }); return JSON.parse(res.data.response_data); }; const route = { path: "/exhibition/:type?", categories: ["travel"], example: "/wuzhongmuseum/exhibition", parameters: { type: "Exhibition type, supported values: short (特别展览), long (常设展览), online (线上展览). Default: all exhibitions." }, name: "Exhibition", maintainers: ["magazian"], radar: [{ source: ["www.wuzhongmuseum.com/portal/exhibition"], target: "/exhibition" }], handler: async (ctx) => { const typeParam = ctx.req.param("type"); const fetchTypes = typeParam ? [typeParam] : [ "short", "long", "online" ]; const typeConfig = { short: "特别展览", long: "常设展览", online: "线上展览" }; const museumName = namespace.zh?.name || namespace.name; const titleTag = fetchTypes.length === 3 ? "展览" : typeConfig[fetchTypes[0]]; const items = (await Promise.all(fetchTypes.map(async (t) => { return (await callCloudApi(`/exhibition?type=${t}&current=1&pageSize=20`))?.data?.list || []; }))).flat().map((item) => { const itemLink = item.external_url ?? `https://www.wuzhongmuseum.com/portal/exhibition/content?id=${item._id}`; const guid = `https://www.wuzhongmuseum.com/portal/exhibition/content?id=${item._id}`; const title = item.name; const pubDate = parseDate(item.created_at * 1e3); const startDate = item.start_time ? dayjs(item.start_time * 1e3).format("YYYY-MM-DD") : void 0; const endDate = item.end_time ? dayjs(item.end_time * 1e3).format("YYYY-MM-DD") : void 0; const location = item.address; const imgUrl = item.cover; return { title, link: itemLink, guid, pubDate, description: renderToString(/* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx("img", { src: imgUrl }), /* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("b", { children: "地点:" }), location || "参考详情"] }), /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("b", { children: "开展:" }), startDate || "未定/常设"] }), /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("b", { children: "闭展:" }), endDate || "未定/常设"] }) ] })), _extra: { museumName, location, startDate, endDate } }; }); return { title: `${museumName} - ${titleTag}`, link: "https://www.wuzhongmuseum.com/portal/exhibition", language: "zh-CN", item: items }; } }; //#endregion export { route };