UNPKG

rsshub

Version:
91 lines (89 loc) 3.17 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import "./cache-SV6W5EPy.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-ByDtry1B.mjs"; import { n as getCitys, r as getDistricts, t as baseUrl } from "./utils-DqExisWN.mjs"; import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/wellcee/rent.tsx const render = (item) => renderToString(/* @__PURE__ */ jsxs(Fragment, { children: [ "租金: ", item.rent, /* @__PURE__ */ jsx("br", {}), item.dailyRent ? /* @__PURE__ */ jsxs(Fragment, { children: [ "日租: ", item.dailyRent, /* @__PURE__ */ jsx("br", {}) ] }) : null, /* @__PURE__ */ jsx("br", {}), item.video ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("video", { controls: true, preload: "metadata", poster: `${item.video}?vframe/png/offset/0`, children: /* @__PURE__ */ jsx("source", { src: item.video, type: "video/mp4" }) }), /* @__PURE__ */ jsx("br", {})] }) : null, item.imgs?.length ? item.imgs.map((img) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("img", { src: img }), /* @__PURE__ */ jsx("br", {})] })) : null ] })); const route = { path: "/rent/:city/:district?", example: "/wellcee/rent/北京", parameters: { city: "城市", district: "地区" }, name: "租房信息", maintainers: ["TonyRL"], handler, url: "www.wellcee.com", description: "支持的城市可以通过 [/wellcee/support-city](https://rsshub.app/wellcee/support-city) 获取" }; async function handler(ctx) { const { city, district = "" } = ctx.req.param(); const cityInfo = (await getCitys()).find((item) => item.chCityName === city); if (!cityInfo) throw new invalid_parameter_default("Invalid city"); let districtInfo; if (district) { const d = (await getDistricts(cityInfo.id)).find((item) => item.name === district); if (!d) throw new invalid_parameter_default("Invalid district"); districtInfo = d; } const items = (await ofetch_default(`${baseUrl}/api/house/filter`, { method: "POST", body: { districtIds: districtInfo?.id ? [districtInfo.id] : [], subways: [], rentTypeIds: [], timeTypeIds: [], price: [], tagTypeIds: [], cityId: cityInfo.id, lang: 1, pn: 1 } })).data.list.map((item) => ({ title: item.address, link: `${baseUrl}/rent-apartment/${item.id}`, description: render(item), pubDate: parseDate(item.loginTime, "X"), author: item.userInfo.name, category: [...item.tags, ...item.typeTags] })); return { title: `${city}${districtInfo?.name ?? ""}租房信息 - Wellcee`, description: `${cityInfo.statics.online_text} ${cityInfo.statics.total_text}`, image: cityInfo.icon, icon: cityInfo.icon, logo: cityInfo.icon, link: `${baseUrl}/rent-apartment/${cityInfo.cityName}/list?cityId=${cityInfo.id}&lang=zh${district ? `#districtIds=${districtInfo?.id}` : ""}`, item: items }; } //#endregion export { route };