🦄 refactor: 调整接口结构

This commit is contained in:
imsyy
2024-12-04 17:47:48 +08:00
parent 0cce0d6067
commit f38d264366
54 changed files with 348 additions and 362 deletions

View File

@@ -4,16 +4,14 @@ import { get } from "../utils/getData.js";
import { getTime } from "../utils/getTime.js";
export const handleRoute = async (_: undefined, noCache: boolean) => {
const { fromCache, data, updateTime } = await getList(noCache);
const listData = await getList(noCache);
const routeData: RouterData = {
name: "huxiu",
title: "虎嗅",
type: "24小时",
link: "https://www.huxiu.com/moment/",
total: data?.length || 0,
updateTime,
fromCache,
data,
total: listData.data?.length || 0,
...listData,
};
return routeData;
};
@@ -38,8 +36,7 @@ const getList = async (noCache: boolean) => {
const matchResult = result.data.match(pattern);
const jsonObject = JSON.parse(matchResult[1]).moment.momentList.moment_list.datalist;
return {
fromCache: result.fromCache,
updateTime: result.updateTime,
...result,
data: jsonObject.map((v: RouterType["huxiu"]) => ({
id: v.object_id,
title: titleProcessing(v.content).title,