mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 13:14:55 +08:00
✨ feat: 水木社区
This commit is contained in:
17
src/router.types.d.ts
vendored
17
src/router.types.d.ts
vendored
@@ -377,4 +377,21 @@ export type RouterType = {
|
|||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
newsmth: {
|
||||||
|
firstArticleId: string;
|
||||||
|
subject: string;
|
||||||
|
article: {
|
||||||
|
topicId: string;
|
||||||
|
postTime: number;
|
||||||
|
subject: string;
|
||||||
|
body: string;
|
||||||
|
account: {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
board: {
|
||||||
|
title: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ const getList = async (noCache: boolean) => {
|
|||||||
const post = v.post;
|
const post = v.post;
|
||||||
return {
|
return {
|
||||||
id: post.id,
|
id: post.id,
|
||||||
|
|
||||||
title: post.title,
|
title: post.title,
|
||||||
desc: post.abstract,
|
desc: post.abstract,
|
||||||
cover: post.cover_url,
|
cover: post.cover_url,
|
||||||
|
|||||||
42
src/routes/newsmth.ts
Normal file
42
src/routes/newsmth.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import type { RouterData } from "../types.js";
|
||||||
|
import type { RouterType } from "../router.types.js";
|
||||||
|
import { get } from "../utils/getData.js";
|
||||||
|
import { getTime } from "../utils/getTime.js";
|
||||||
|
|
||||||
|
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||||
|
const listData = await getList(noCache);
|
||||||
|
const routeData: RouterData = {
|
||||||
|
name: "newsmth",
|
||||||
|
title: "水木社区",
|
||||||
|
type: "热门话题",
|
||||||
|
description: "水木社区是一个源于清华的高知社群。",
|
||||||
|
link: "https://www.newsmth.net/",
|
||||||
|
total: listData.data?.length || 0,
|
||||||
|
...listData,
|
||||||
|
};
|
||||||
|
return routeData;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getList = async (noCache: boolean) => {
|
||||||
|
const url = `https://wap.newsmth.net/wap/api/hot/global`;
|
||||||
|
const result = await get({ url, noCache });
|
||||||
|
const list = result.data?.data?.topics;
|
||||||
|
return {
|
||||||
|
...result,
|
||||||
|
data: list.map((v: RouterType["newsmth"]) => {
|
||||||
|
const post = v.article;
|
||||||
|
const url = `https://wap.newsmth.net/article/${post.topicId}?title=${v.board?.title}&from=home`;
|
||||||
|
return {
|
||||||
|
id: v.firstArticleId,
|
||||||
|
title: post.subject,
|
||||||
|
desc: post.body,
|
||||||
|
cover: undefined,
|
||||||
|
author: post?.account?.name,
|
||||||
|
hot: undefined,
|
||||||
|
timestamp: getTime(post.postTime),
|
||||||
|
url,
|
||||||
|
mobileUrl: url,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user