* feat(pencilnews): 新增铅笔道文章列表 * 📝 docs(pencilnews/index.ts): 更新维护者信息 * feat(route): 新增钛媒体快讯 新增了钛媒体(TMTPost)的命名空间定义和快讯路由支持。通过 `nictation.ts` 文件实现了从钛媒体 API 获取最新快讯数据的功能 * ✨ feat(tmtpost/nictation.ts): 添加 `share_link` 字段并更新链接格式 在请求字段中添加 `share_link` 以确保获取分享链接数据。同时,更新文章链接的生成逻辑,使用 `guid` 替代 `id`,以匹配 TMTPost 的最新 URL 格式。这些更改确保数据完整性和链接的准确性,提升用户体验。 * Update lib/routes/tmtpost/nictation.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/tmtpost/nictation.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/tmtpost/nictation.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> ---------
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { Route } from '@/types';
|
|
import got from '@/utils/got';
|
|
import { parseDate } from '@/utils/parse-date';
|
|
|
|
export const route: Route = {
|
|
path: '/nictation',
|
|
categories: ['new-media'],
|
|
example: '/tmtpost/word',
|
|
parameters: {},
|
|
features: {
|
|
requireConfig: false,
|
|
requirePuppeteer: false,
|
|
antiCrawler: false,
|
|
supportBT: false,
|
|
supportPodcast: false,
|
|
supportScihub: false,
|
|
},
|
|
radar: {
|
|
source: ['www.tmtpost.com'],
|
|
},
|
|
name: '快报',
|
|
maintainers: ['defp'],
|
|
handler,
|
|
url: 'www.tmtpost.com/nictation',
|
|
};
|
|
|
|
async function handler() {
|
|
const currentTime = Math.floor(Date.now() / 1000);
|
|
const oneHourAgo = currentTime - 3600;
|
|
const url = 'https://api.tmtpost.com/v1/word/list';
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url,
|
|
searchParams: {
|
|
time_start: oneHourAgo,
|
|
time_end: currentTime,
|
|
limit: 40,
|
|
fields: ['share_description', 'share_image', 'word_comments', 'stock_list', 'is_important', 'duration', 'word_classify', 'share_link'].join(';'),
|
|
},
|
|
headers: {
|
|
'app-version': 'web1.0',
|
|
},
|
|
});
|
|
|
|
const data = response.data.data;
|
|
|
|
return {
|
|
title: '钛媒体 - 快报',
|
|
link: 'https://www.tmtpost.com/nictation',
|
|
item: data.map((item) => ({
|
|
title: item.title,
|
|
description: item.detail,
|
|
pubDate: parseDate(item.time_published, 'X'),
|
|
link: item.share_link || `https://www.tmtpost.com/nictation/${item.guid}.html`,
|
|
author: item.author_name,
|
|
})),
|
|
};
|
|
}
|