rsshub
Version:
Make RSS Great Again!
53 lines (52 loc) • 1.36 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
//#region lib/routes/vgnlab/index.ts
const route = {
path: "/",
categories: ["game"],
example: "/vgnlab",
radar: [{ source: ["www.vgnlab.com.cn/web/news"] }],
name: "新闻中心",
maintainers: ["wyangx"],
handler,
url: "www.vgnlab.com.cn/web/news"
};
async function handler() {
const baseUrl = "https://www.vgnlab.com.cn";
const { data } = await rofetch(`${baseUrl}/api/news/list`, {
method: "POST",
body: {
app_type: "pc",
app_type_name: "PC",
page: 1,
page_size: 12
}
});
const list = [data.top, ...data.list].filter((item) => item?.id).map((item) => ({
title: item.title,
link: `${baseUrl}/web/news-${item.id}`,
pubDate: parseDate(item.publish_time * 1e3),
image: item.img_url,
id: item.id
}));
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const { data } = await rofetch(`${baseUrl}/api/news/detail`, {
method: "POST",
body: {
app_type: "pc",
app_type_name: "PC",
id: item.id
}
});
item.description = data.content;
return item;
})));
return {
title: "VGN官网 - 新闻中心",
link: `${baseUrl}/web/news`,
item: items
};
}
//#endregion
export { route };