UNPKG

rsshub

Version:
100 lines (99 loc) 3.44 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 { Agent } from "undici"; import { jsx, jsxs } from "hono/jsx/jsx-runtime"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/zjmuseum/namespace.ts const namespace = { name: "Zhejiang Provincial Museum", url: "www.zjmuseum.com.cn/cn/", zh: { name: "浙江省博物馆" } }; //#endregion //#region lib/routes/zjmuseum/temporaryexhibition.tsx const route = { path: "/exhibition/:type?", categories: ["travel"], example: "/zjmuseum/exhibition/ondisplay", parameters: { type: "Temporary Exhibition type, supported values: ondisplay (正在展出)、forecast(即将开始)、review(展览回顾). Default: All exhibitions (ondisplay, forecast and review)." }, name: "Temporary Exhibition", maintainers: ["magazian"], radar: [{ source: ["www.zjmuseum.com.cn/cn/"], target: "/exhibition/:type?" }], handler: async (ctx) => { const baseUrl = "https://www.zjmuseum.com.cn"; const apiUrl = `${baseUrl}/api/exhibition/page`; const apiConfig = { ondisplay: { name: "正在展出", payload: { hasOpen: "1" } }, forecast: { name: "即将开始", payload: { hasOpen: "2" } }, review: { name: "展览回顾", payload: { hasOpen: "3" } } }; const typeParam = ctx.req.param("type"); const fetchTypes = typeParam ? [typeParam] : Object.keys(apiConfig); const museumName = namespace.zh?.name || namespace.name; const titleTag = typeParam ? apiConfig[typeParam]?.name : "全部展览"; const items = (await Promise.all(fetchTypes.map(async (t) => { const config = apiConfig[t]; return (((await got_default({ method: "post", url: apiUrl, dispatcher: new Agent({ connect: { ecdhCurve: "X25519:P-256:P-521:P-384" } }), json: { siteId: 22, type: 2, pageNum: 1, pageSize: 10, startDate: "", endDate: "", hasLink: "", ...config.payload } })).data?.data)?.[1] || []).map((item) => { const title = item.title; const itemLink = `${baseUrl}/cn/#/Exhibition/TemporaryExhibition/${item.content_id}`; const pubDate = timezone(parseDate(item.create_time), 8); const startDate = item.start_time.split("T", 1)[0]; const endDate = item.end_time.split("T", 1)[0]; const location = [item.museum_area, item.address].filter(Boolean).join(" "); return { title, link: itemLink, pubDate, description: renderToString(/* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx("img", { src: `${baseUrl}${item.cover_url}` }), /* @__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 } }; }); }))).flat(); return { title: `${museumName} - 临时展览 - ${titleTag}`, link: `${baseUrl}/cn/#/Exhibition/TemporaryExhibition`, language: "zh-CN", item: items }; } }; //#endregion export { route };