UNPKG

rsshub

Version:
88 lines (87 loc) 3.05 kB
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { t as timezone } from "./timezone-BBvDwS_3.mjs"; import { t as namespace } from "./namespace-a6pdF4qB.mjs"; import { jsx, jsxs } from "hono/jsx/jsx-runtime"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/lnmuseum/temporary.tsx const route = { path: "/exhibition/temporary/:type?", categories: ["travel"], example: "/lnmuseum/exhibition/temporary/now", params: { type: "Temporary Exhibition type, supported values: now (正在展出)、past(展览回顾)。Default: All temporary exhibitions (now and past)." }, name: "Temporary Exhibition", maintainers: ["magazian"], radar: [{ source: ["www.lnmuseum.com.cn"], target: "/exhibition/temporary" }], handler: async (ctx) => { const typeParam = ctx.req.param("type"); const fetchTypes = typeParam && (typeParam === "now" || typeParam === "past") ? [typeParam] : ["now", "past"]; const baseUrl = "https://www.lnmuseum.com.cn"; const apiUrl = `${baseUrl}/singleMuseum/applet/exhibition/zlList`; const apiConfig = { now: { typeId: "1", name: "正在展出" }, past: { typeId: "3", name: "展览回顾" } }; const museumName = namespace.zh?.name || namespace.name; const titleTag = fetchTypes.length === 2 ? "全部展览" : apiConfig[fetchTypes[0]]?.name; const items = (await Promise.all(fetchTypes.map(async (t) => { const config = apiConfig[t]; try { return ((await got_default({ method: "get", url: apiUrl, searchParams: { currentPage: 1, size: 9, type: config.typeId, _t: Date.now() } })).data?.result?.records || []).map((item) => { const title = item.name; const itemLink = `${baseUrl}/#/exhibition/detail?id=${item.id}&pageType=1`; const pubDate = timezone(parseDate(item.createTime), 8); const startDate = item.beginTime; const endDate = item.endTime; const location = item.address; return { title, link: itemLink, pubDate, description: renderToString(/* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx("img", { src: `${baseUrl}${item.mainPic}` }), /* @__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 } }; }); } catch { return []; } }))).flat(); return { title: `${museumName} - 临时展览 - ${titleTag}`, link: `${baseUrl}/#/exhibition?type=1`, language: "zh-CN", item: items }; } }; //#endregion export { route };