feat: 新增 虎嗅 & 爱范儿

This commit is contained in:
imsyy
2024-05-16 18:10:34 +08:00
parent cdf2479044
commit 679fdab87e
5 changed files with 110 additions and 3 deletions

37
src/routes/ifanr.ts Normal file
View File

@@ -0,0 +1,37 @@
import type { RouterData } from "../types.js";
import type { RouterType } from "../router.types.js";
import { get } from "../utils/getData.js";
export const handleRoute = async (_: undefined, noCache: boolean) => {
const { fromCache, data, updateTime } = await getList(noCache);
const routeData: RouterData = {
name: "ifanr",
title: "爱范儿",
type: "快讯",
description: "15秒了解全球新鲜事",
link: "https://www.ifanr.com/digest/",
total: data?.length || 0,
updateTime,
fromCache,
data,
};
return routeData;
};
const getList = async (noCache: boolean) => {
const url = "https://sso.ifanr.com/api/v5/wp/buzz/?limit=20&offset=0";
const result = await get({ url, noCache });
const list = result.data.objects;
return {
fromCache: result.fromCache,
updateTime: result.updateTime,
data: list.map((v: RouterType["ifanr"]) => ({
id: v.id,
title: v.post_title,
desc: v.post_content,
hot: v.like_count || v.comment_count,
url: `https://www.ifanr.com/${v.id}` || v.buzz_original_url,
mobileUrl: `https://www.ifanr.com/digest/${v.id}` || v.buzz_original_url,
})),
};
};