feat: 微信读书类目增加

This commit is contained in:
helti
2025-02-09 10:58:07 +08:00
parent 26f10d0c6a
commit 22a14dd64e

View File

@@ -1,15 +1,30 @@
import type { RouterData } from "../types.js"; import type { ListContext, RouterData } from "../types.js";
import type { RouterType } from "../router.types.js"; import type { RouterType } from "../router.types.js";
import { get } from "../utils/getData.js"; import { get } from "../utils/getData.js";
import getWereadID from "../utils/getToken/weread.js"; import getWereadID from "../utils/getToken/weread.js";
import { getTime } from "../utils/getTime.js"; import { getTime } from "../utils/getTime.js";
export const handleRoute = async (_: undefined, noCache: boolean) => { const typeMap: Record<string, string> = {
const listData = await getList(noCache); rising: "飙升榜",
hot_search: "热搜榜",
newbook: "新书榜",
general_novel_rising: "小说榜",
all: "总榜",
};
export const handleRoute = async (c: ListContext, noCache: boolean) => {
const type = c.req.query("type") || "rising";
const listData = await getList(noCache, type);
const routeData: RouterData = { const routeData: RouterData = {
name: "weread", name: "weread",
title: "微信读书", title: "微信读书",
type: "飙升榜", type: `${typeMap[type]}`,
params: {
type: {
name: "排行榜分区",
type: typeMap,
},
},
link: "https://weread.qq.com/", link: "https://weread.qq.com/",
total: listData.data?.length || 0, total: listData.data?.length || 0,
...listData, ...listData,
@@ -17,8 +32,8 @@ export const handleRoute = async (_: undefined, noCache: boolean) => {
return routeData; return routeData;
}; };
const getList = async (noCache: boolean) => { const getList = async (noCache: boolean, type='rising') => {
const url = `https://weread.qq.com/web/bookListInCategory/rising?rank=1`; const url = `https://weread.qq.com/web/bookListInCategory/${type}?rank=1`;
const result = await get({ const result = await get({
url, url,
noCache, noCache,