mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 21:24:55 +08:00
🦄 refactor: 调整接口结构
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user