mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 13:14:55 +08:00
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
> 🟢 状态正常 / 🟠 可能失效 / ❌ 无法使用 / ⚠️ 需要科学上网
|
> 🟢 状态正常 / 🟠 可能失效 / ❌ 无法使用 / ⚠️ 需要科学上网
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>查看全部接口状态</summary>
|
||||||
|
|
||||||
| **站点** | **类别** | **调用名称** | **状态** |
|
| **站点** | **类别** | **调用名称** | **状态** |
|
||||||
| ---------------- | ------------ | -------------- | -------- |
|
| ---------------- | ------------ | -------------- | -------- |
|
||||||
| 哔哩哔哩 | 热门榜 | bilibili | 🟢 |
|
| 哔哩哔哩 | 热门榜 | bilibili | 🟢 |
|
||||||
@@ -52,10 +55,13 @@
|
|||||||
| CSDN | 排行榜 | csdn | 🟢 |
|
| CSDN | 排行榜 | csdn | 🟢 |
|
||||||
| 稀土掘金 | 热榜 | juejin | 🟢 |
|
| 稀土掘金 | 热榜 | juejin | 🟢 |
|
||||||
| 腾讯新闻 | 热点榜 | qq-news | 🟢 |
|
| 腾讯新闻 | 热点榜 | qq-news | 🟢 |
|
||||||
|
| 新浪网 | 热榜 | sina | 🟢 |
|
||||||
|
| 新浪新闻 | 热点榜 | sina-news | 🟢 |
|
||||||
| 网易新闻 | 热点榜 | netease-news | 🟢 |
|
| 网易新闻 | 热点榜 | netease-news | 🟢 |
|
||||||
| 吾爱破解 | 榜单 | 52pojie | ❌ |
|
| 吾爱破解 | 榜单 | 52pojie | ❌ |
|
||||||
| 全球主机交流 | 榜单 | hostloc | ❌ |
|
| 全球主机交流 | 榜单 | hostloc | ❌ |
|
||||||
| 虎嗅 | 24小时 | huxiu | 🟢 |
|
| 虎嗅 | 24小时 | huxiu | 🟢 |
|
||||||
|
| 虎扑 | 步行街热帖 | hupu | 🟢 |
|
||||||
| 爱范儿 | 快讯 | ifanr | 🟢 |
|
| 爱范儿 | 快讯 | ifanr | 🟢 |
|
||||||
| 英雄联盟 | 更新公告 | lol | 🟢 |
|
| 英雄联盟 | 更新公告 | lol | 🟢 |
|
||||||
| 原神 | 最新消息 | genshin | 🟢 |
|
| 原神 | 最新消息 | genshin | 🟢 |
|
||||||
@@ -69,6 +75,8 @@
|
|||||||
| 中国地震台 | 地震速报 | earthquake | 🟢 |
|
| 中国地震台 | 地震速报 | earthquake | 🟢 |
|
||||||
| 历史上的今天 | 月-日 | history | 🟢 |
|
| 历史上的今天 | 月-日 | history | 🟢 |
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## ⚙️ 使用
|
## ⚙️ 使用
|
||||||
|
|
||||||
本项目支持 `Node.js` 调用,可在安装完成后调用 `serveHotApi` 来开启服务器
|
本项目支持 `Node.js` 调用,可在安装完成后调用 `serveHotApi` 来开启服务器
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dailyhot-api",
|
"name": "dailyhot-api",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"description": "An Api on Today's Hot list",
|
"description": "An Api on Today's Hot list",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"API",
|
"API",
|
||||||
|
|||||||
30
src/router.types.d.ts
vendored
30
src/router.types.d.ts
vendored
@@ -277,4 +277,34 @@ export type RouterType = {
|
|||||||
cover: string;
|
cover: string;
|
||||||
pic_share: string;
|
pic_share: string;
|
||||||
};
|
};
|
||||||
|
hupu: {
|
||||||
|
tid: number;
|
||||||
|
title: string;
|
||||||
|
replies: number;
|
||||||
|
username: string;
|
||||||
|
time: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
sina: {
|
||||||
|
base: {
|
||||||
|
base: {
|
||||||
|
uniqueId: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
info: {
|
||||||
|
hotValue: string;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"sina-news": {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
media: string;
|
||||||
|
url: string;
|
||||||
|
create_date: string;
|
||||||
|
create_time: string;
|
||||||
|
top_num: string;
|
||||||
|
time: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "36kr",
|
name: "36kr",
|
||||||
title: "36氪",
|
title: "36氪",
|
||||||
type: "热榜",
|
type: "热榜",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "热榜分类",
|
name: "热榜分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "52pojie",
|
name: "52pojie",
|
||||||
title: "吾爱破解",
|
title: "吾爱破解",
|
||||||
type: "榜单",
|
type: "榜单",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "榜单分类",
|
name: "榜单分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
title: "AcFun",
|
title: "AcFun",
|
||||||
type: "排行榜",
|
type: "排行榜",
|
||||||
description: "AcFun是一家弹幕视频网站,致力于为每一个人带来欢乐。",
|
description: "AcFun是一家弹幕视频网站,致力于为每一个人带来欢乐。",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "频道",
|
name: "频道",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "baidu",
|
name: "baidu",
|
||||||
title: "百度",
|
title: "百度",
|
||||||
type: "热搜榜",
|
type: "热搜榜",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "热搜类别",
|
name: "热搜类别",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
title: "哔哩哔哩",
|
title: "哔哩哔哩",
|
||||||
type: "热门榜",
|
type: "热门榜",
|
||||||
description: "你所热爱的,就是你的生活",
|
description: "你所热爱的,就是你的生活",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "排行榜分区",
|
name: "排行榜分区",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ export const handleRoute = async (_: undefined, noCache: boolean) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 数据处理
|
// 数据处理
|
||||||
const getNumbers = (text: string | undefined) => {
|
const getNumbers = (text: string | undefined): number => {
|
||||||
if (!text) return 10000000;
|
if (!text) return 0;
|
||||||
const regex = /\d+/;
|
const regex = /\d+/;
|
||||||
const match = text.match(regex);
|
const match = text.match(regex);
|
||||||
if (match) {
|
if (match) {
|
||||||
return Number(match[0]);
|
return Number(match[0]);
|
||||||
} else {
|
} else {
|
||||||
return 10000000;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,7 +44,8 @@ const getList = async (noCache: boolean) => {
|
|||||||
const listData = listDom.toArray().map((item) => {
|
const listData = listDom.toArray().map((item) => {
|
||||||
const dom = $(item);
|
const dom = $(item);
|
||||||
const url = dom.find("a").attr("href") || undefined;
|
const url = dom.find("a").attr("href") || undefined;
|
||||||
const score = dom.find(".rating_nums").text() ?? "0.0";
|
const scoreDom = dom.find(".rating_nums");
|
||||||
|
const score = scoreDom.length > 0 ? scoreDom.text() : "0.0";
|
||||||
return {
|
return {
|
||||||
id: getNumbers(url),
|
id: getNumbers(url),
|
||||||
title: `【${score}】${dom.find("a").attr("title")}`,
|
title: `【${score}】${dom.find("a").attr("title")}`,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "earthquake",
|
name: "earthquake",
|
||||||
title: "中国地震台",
|
title: "中国地震台",
|
||||||
type: "地震速报",
|
type: "地震速报",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "速报分类",
|
name: "速报分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "genshin",
|
name: "genshin",
|
||||||
title: "原神",
|
title: "原神",
|
||||||
type: "最新动态",
|
type: "最新动态",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "榜单分类",
|
name: "榜单分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
title: "HelloGitHub",
|
title: "HelloGitHub",
|
||||||
type: "热门仓库",
|
type: "热门仓库",
|
||||||
description: "分享 GitHub 上有趣、入门级的开源项目",
|
description: "分享 GitHub 上有趣、入门级的开源项目",
|
||||||
parame: {
|
params: {
|
||||||
sort: {
|
sort: {
|
||||||
name: "排行榜分区",
|
name: "排行榜分区",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import { getCurrentDateTime } from "../utils/getTime.js";
|
|||||||
|
|
||||||
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||||
// 获取日期
|
// 获取日期
|
||||||
const day = c.req.query("day") || getCurrentDateTime().day;
|
const day = c.req.query("day") || getCurrentDateTime(true).day;
|
||||||
const month = c.req.query("month") || getCurrentDateTime().month;
|
const month = c.req.query("month") || getCurrentDateTime(true).month;
|
||||||
const { fromCache, data, updateTime } = await getList({ month, day }, noCache);
|
const { fromCache, data, updateTime } = await getList({ month, day }, noCache);
|
||||||
const routeData: RouterData = {
|
const routeData: RouterData = {
|
||||||
name: "history",
|
name: "history",
|
||||||
title: "历史上的今天",
|
title: "历史上的今天",
|
||||||
type: `${month}-${day}`,
|
type: `${month}-${day}`,
|
||||||
parame: {
|
params: {
|
||||||
month: "月份",
|
month: "月份",
|
||||||
day: "日期",
|
day: "日期",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "honkai",
|
name: "honkai",
|
||||||
title: "崩坏3",
|
title: "崩坏3",
|
||||||
type: "最新动态",
|
type: "最新动态",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "榜单分类",
|
name: "榜单分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "hostloc",
|
name: "hostloc",
|
||||||
title: "全球主机交流",
|
title: "全球主机交流",
|
||||||
type: "榜单",
|
type: "榜单",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "榜单分类",
|
name: "榜单分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
51
src/routes/hupu.ts
Normal file
51
src/routes/hupu.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import type { RouterData, ListContext, Options } from "../types.js";
|
||||||
|
import type { RouterType } from "../router.types.js";
|
||||||
|
import { get } from "../utils/getData.js";
|
||||||
|
|
||||||
|
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||||
|
const type = c.req.query("type") || "1";
|
||||||
|
const { fromCache, data, updateTime } = await getList({ type }, noCache);
|
||||||
|
const routeData: RouterData = {
|
||||||
|
name: "hupu",
|
||||||
|
title: "虎扑",
|
||||||
|
type: "步行街热帖",
|
||||||
|
params: {
|
||||||
|
type: {
|
||||||
|
name: "榜单分类",
|
||||||
|
type: {
|
||||||
|
1: "主干道",
|
||||||
|
6: "恋爱区",
|
||||||
|
11: "校园区",
|
||||||
|
12: "历史区",
|
||||||
|
612: "摄影区",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
link: "https://bbs.hupu.com/all-gambia",
|
||||||
|
total: data?.length || 0,
|
||||||
|
updateTime,
|
||||||
|
fromCache,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
return routeData;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getList = async (options: Options, noCache: boolean) => {
|
||||||
|
const { type } = options;
|
||||||
|
const url = `https://m.hupu.com/api/v2/bbs/topicThreads?topicId=${type}&page=1`;
|
||||||
|
const result = await get({ url, noCache });
|
||||||
|
const list = result.data.data.topicThreads;
|
||||||
|
return {
|
||||||
|
fromCache: result.fromCache,
|
||||||
|
updateTime: result.updateTime,
|
||||||
|
data: list.map((v: RouterType["hupu"]) => ({
|
||||||
|
id: v.tid,
|
||||||
|
title: v.title,
|
||||||
|
author: v.username,
|
||||||
|
hot: v.replies,
|
||||||
|
timestamp: null,
|
||||||
|
url: `https://bbs.hupu.com/${v.tid}.html`,
|
||||||
|
mobileUrl: v.url,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
137
src/routes/sina-news.ts
Normal file
137
src/routes/sina-news.ts
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
import type { RouterData, ListContext, Options } from "../types.js";
|
||||||
|
import type { RouterType } from "../router.types.js";
|
||||||
|
import { getTime, getCurrentDateTime } from "../utils/getTime.js";
|
||||||
|
import { get } from "../utils/getData.js";
|
||||||
|
|
||||||
|
// 榜单类别
|
||||||
|
const listType = {
|
||||||
|
"1": {
|
||||||
|
name: "总排行",
|
||||||
|
www: "news",
|
||||||
|
params: "www_www_all_suda_suda",
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
name: "视频排行",
|
||||||
|
www: "news",
|
||||||
|
params: "video_news_all_by_vv",
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
name: "图片排行",
|
||||||
|
www: "news",
|
||||||
|
params: "total_slide_suda",
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
name: "国内新闻",
|
||||||
|
www: "news",
|
||||||
|
params: "news_china_suda",
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
name: "国际新闻",
|
||||||
|
www: "news",
|
||||||
|
params: "news_world_suda",
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
|
name: "社会新闻",
|
||||||
|
www: "news",
|
||||||
|
params: "news_society_suda",
|
||||||
|
},
|
||||||
|
"7": {
|
||||||
|
name: "体育新闻",
|
||||||
|
www: "sports",
|
||||||
|
params: "sports_suda",
|
||||||
|
},
|
||||||
|
"8": {
|
||||||
|
name: "财经新闻",
|
||||||
|
www: "finance",
|
||||||
|
params: "finance_0_suda",
|
||||||
|
},
|
||||||
|
"9": {
|
||||||
|
name: "娱乐新闻",
|
||||||
|
www: "ent",
|
||||||
|
params: "ent_suda",
|
||||||
|
},
|
||||||
|
"10": {
|
||||||
|
name: "科技新闻",
|
||||||
|
www: "tech",
|
||||||
|
params: "tech_news_suda",
|
||||||
|
},
|
||||||
|
"11": {
|
||||||
|
name: "军事新闻",
|
||||||
|
www: "news",
|
||||||
|
params: "news_mil_suda",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||||
|
const type = c.req.query("type") || "1";
|
||||||
|
const { fromCache, data, updateTime } = await getList({ type }, noCache);
|
||||||
|
const routeData: RouterData = {
|
||||||
|
name: "sina-news",
|
||||||
|
title: "新浪新闻",
|
||||||
|
type: listType[type].name,
|
||||||
|
params: {
|
||||||
|
type: {
|
||||||
|
name: "榜单分类",
|
||||||
|
type: Object.fromEntries(Object.entries(listType).map(([key, value]) => [key, value.name])),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
link: "https://sinanews.sina.cn/",
|
||||||
|
total: data?.length || 0,
|
||||||
|
updateTime,
|
||||||
|
fromCache,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
return routeData;
|
||||||
|
};
|
||||||
|
|
||||||
|
// JSONP 处理
|
||||||
|
const parseData = (data: string) => {
|
||||||
|
// 移除前后多余空白
|
||||||
|
if (!data) throw new Error("Input data is empty or invalid");
|
||||||
|
// 提取 JSON 字符串部分
|
||||||
|
const prefix = "var data = ";
|
||||||
|
if (!data.startsWith(prefix))
|
||||||
|
throw new Error("Input data does not start with the expected prefix");
|
||||||
|
let jsonString = data.slice(prefix.length).trim();
|
||||||
|
// 确保字符串以 ';' 结尾并移除它
|
||||||
|
if (jsonString.endsWith(";")) {
|
||||||
|
jsonString = jsonString.slice(0, -1).trim();
|
||||||
|
} else {
|
||||||
|
throw new Error("Input data does not end with a semicolon");
|
||||||
|
}
|
||||||
|
// 格式是否正确
|
||||||
|
if (jsonString.startsWith("{") && jsonString.endsWith("}")) {
|
||||||
|
// 解析为 JSON 对象
|
||||||
|
try {
|
||||||
|
const jsonData = JSON.parse(jsonString);
|
||||||
|
return jsonData;
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error("Failed to parse JSON: " + error.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error("Invalid JSON format");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getList = async (options: Options, noCache: boolean) => {
|
||||||
|
const { type } = options;
|
||||||
|
// 必要数据
|
||||||
|
const { params, www } = listType[type];
|
||||||
|
const { year, month, day } = getCurrentDateTime(true);
|
||||||
|
const url = `https://top.${www}.sina.com.cn/ws/GetTopDataList.php?top_type=day&top_cat=${params}&top_time=${year + month + day}&top_show_num=50`;
|
||||||
|
const result = await get({ url, noCache });
|
||||||
|
const list = parseData(result.data).data;
|
||||||
|
return {
|
||||||
|
fromCache: result.fromCache,
|
||||||
|
updateTime: result.updateTime,
|
||||||
|
data: list.map((v: RouterType["sina-news"]) => ({
|
||||||
|
id: v.id,
|
||||||
|
title: v.title,
|
||||||
|
author: v.media || null,
|
||||||
|
hot: parseFloat(v.top_num.replace(/,/g, "")),
|
||||||
|
timestamp: getTime(v.create_date + " " + v.create_time),
|
||||||
|
url: v.url,
|
||||||
|
mobileUrl: v.url,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
62
src/routes/sina.ts
Normal file
62
src/routes/sina.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import type { RouterData, ListContext, Options } from "../types.js";
|
||||||
|
import type { RouterType } from "../router.types.js";
|
||||||
|
import { parseChineseNumber } from "../utils/getNum.js";
|
||||||
|
import { get } from "../utils/getData.js";
|
||||||
|
|
||||||
|
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||||
|
const type = c.req.query("type") || "1";
|
||||||
|
const { fromCache, data, updateTime } = await getList({ type }, noCache);
|
||||||
|
const routeData: RouterData = {
|
||||||
|
name: "sina",
|
||||||
|
title: "新浪网",
|
||||||
|
type: "热榜太多,一个就够",
|
||||||
|
params: {
|
||||||
|
type: {
|
||||||
|
name: "榜单分类",
|
||||||
|
type: {
|
||||||
|
all: "新浪热榜",
|
||||||
|
hotcmnt: "热议榜",
|
||||||
|
minivideo: "视频热榜",
|
||||||
|
ent: "娱乐热榜",
|
||||||
|
ai: "AI热榜",
|
||||||
|
auto: "汽车热榜",
|
||||||
|
mother: "育儿热榜",
|
||||||
|
fashion: "时尚热榜",
|
||||||
|
travel: "旅游热榜",
|
||||||
|
esg: "ESG热榜",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
link: "https://sinanews.sina.cn/",
|
||||||
|
total: data?.length || 0,
|
||||||
|
updateTime,
|
||||||
|
fromCache,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
return routeData;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getList = async (options: Options, noCache: boolean) => {
|
||||||
|
const { type } = options;
|
||||||
|
const url = `https://newsapp.sina.cn/api/hotlist?newsId=HB-1-snhs%2Ftop_news_list-${type}`;
|
||||||
|
const result = await get({ url, noCache });
|
||||||
|
const list = result.data.data.hotList;
|
||||||
|
return {
|
||||||
|
fromCache: result.fromCache,
|
||||||
|
updateTime: result.updateTime,
|
||||||
|
data: list.map((v: RouterType["sina"]) => {
|
||||||
|
const base = v.base;
|
||||||
|
const info = v.info;
|
||||||
|
return {
|
||||||
|
id: base.base.uniqueId,
|
||||||
|
title: info.title,
|
||||||
|
desc: null,
|
||||||
|
author: null,
|
||||||
|
timestamp: null,
|
||||||
|
hot: parseChineseNumber(info.hotValue),
|
||||||
|
url: base.base.url,
|
||||||
|
mobileUrl: base.base.url,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -10,7 +10,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "sspai",
|
name: "sspai",
|
||||||
title: "少数派",
|
title: "少数派",
|
||||||
type: "热榜",
|
type: "热榜",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "分类",
|
name: "分类",
|
||||||
type: ["热门文章", "应用推荐", "生活方式", "效率技巧", "少数派播客"],
|
type: ["热门文章", "应用推荐", "生活方式", "效率技巧", "少数派播客"],
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "starrail",
|
name: "starrail",
|
||||||
title: "崩坏:星穹铁道",
|
title: "崩坏:星穹铁道",
|
||||||
type: "最新动态",
|
type: "最新动态",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "榜单分类",
|
name: "榜单分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "v2ex",
|
name: "v2ex",
|
||||||
title: "V2EX",
|
title: "V2EX",
|
||||||
type: "主题榜",
|
type: "主题榜",
|
||||||
parame: {
|
params: {
|
||||||
type: {
|
type: {
|
||||||
name: "榜单分类",
|
name: "榜单分类",
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
name: "weatheralarm",
|
name: "weatheralarm",
|
||||||
title: "中央气象台",
|
title: "中央气象台",
|
||||||
type: type || "全国气象预警",
|
type: type || "全国气象预警",
|
||||||
parame: {
|
params: {
|
||||||
province: {
|
province: {
|
||||||
name: "预警区域",
|
name: "预警区域",
|
||||||
value: "省份名称( 例如:广东省 )",
|
value: "省份名称( 例如:广东省 )",
|
||||||
|
|||||||
2
src/types.d.ts
vendored
2
src/types.d.ts
vendored
@@ -22,7 +22,7 @@ export type RouterData = {
|
|||||||
title: string;
|
title: string;
|
||||||
type: string;
|
type: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
parame?: Record<string, string | object>;
|
params?: Record<string, string | object>;
|
||||||
total: number;
|
total: number;
|
||||||
link?: string;
|
link?: string;
|
||||||
updateTime: string;
|
updateTime: string;
|
||||||
|
|||||||
20
src/utils/getNum.ts
Normal file
20
src/utils/getNum.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export const parseChineseNumber = (chineseNumber: string): number => {
|
||||||
|
// 单位对照表
|
||||||
|
const units: { [key: string]: number } = {
|
||||||
|
亿: 1e8,
|
||||||
|
万: 1e4,
|
||||||
|
千: 1e3,
|
||||||
|
百: 1e2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 遍历单位对照表
|
||||||
|
for (const unit in units) {
|
||||||
|
if (chineseNumber.includes(unit)) {
|
||||||
|
// 转换为数字
|
||||||
|
const numberPart = parseFloat(chineseNumber.replace(unit, ""));
|
||||||
|
return numberPart * units[unit];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseFloat(chineseNumber);
|
||||||
|
};
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
interface CurrentDateTime {
|
interface CurrentDateTime {
|
||||||
year: number;
|
year: string;
|
||||||
month: number;
|
month: string;
|
||||||
day: number;
|
day: string;
|
||||||
hour: number;
|
hour: string;
|
||||||
minute: number;
|
minute: string;
|
||||||
second: number;
|
second: string;
|
||||||
}
|
}
|
||||||
export const getTime = (timeInput: string | number): number | null => {
|
export const getTime = (timeInput: string | number): number | null => {
|
||||||
try {
|
try {
|
||||||
@@ -65,15 +65,18 @@ export const getTime = (timeInput: string | number): number | null => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCurrentDateTime = (): CurrentDateTime => {
|
export const getCurrentDateTime = (padZero: boolean = false): CurrentDateTime => {
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
|
|
||||||
|
// 补零
|
||||||
|
const pad = (num: number): string => (num < 10 ? `0${num}` : `${num}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
year: now.year(),
|
year: now.year().toString(),
|
||||||
month: now.month() + 1,
|
month: padZero ? pad(now.month() + 1) : (now.month() + 1).toString(),
|
||||||
day: now.date(),
|
day: padZero ? pad(now.date()) : now.date().toString(),
|
||||||
hour: now.hour(),
|
hour: padZero ? pad(now.hour()) : now.hour().toString(),
|
||||||
minute: now.minute(),
|
minute: padZero ? pad(now.minute()) : now.minute().toString(),
|
||||||
second: now.second(),
|
second: padZero ? pad(now.second()) : now.second().toString(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user