🦄 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,17 +4,15 @@ 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: "weibo",
title: "微博",
type: "热搜榜",
description: "实时热点,每分钟更新一次",
link: "https://s.weibo.com/top/summary/",
total: data?.length || 0,
updateTime,
fromCache,
data,
total: listData.data?.length || 0,
...listData,
};
return routeData;
};
@@ -24,8 +22,7 @@ const getList = async (noCache: boolean) => {
const result = await get({ url, noCache, ttl: 60 });
const list = result.data.data.realtime;
return {
fromCache: result.fromCache,
updateTime: result.updateTime,
...result,
data: list.map((v: RouterType["weibo"]) => {
const key = v.word_scheme ? v.word_scheme : `#${v.word}`;
return {