mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
feat: 微信开放平台相关路由代码简化 (#3804)
This commit is contained in:
@@ -1790,13 +1790,11 @@ router.get('/tianya/comments/:userid', require('./routes/tianya/comments'));
|
|||||||
router.get('/eleme/open/announce', require('./routes/eleme/open/announce'));
|
router.get('/eleme/open/announce', require('./routes/eleme/open/announce'));
|
||||||
router.get('/eleme/open-be/announce', require('./routes/eleme/open-be/announce'));
|
router.get('/eleme/open-be/announce', require('./routes/eleme/open-be/announce'));
|
||||||
|
|
||||||
// wechat-open
|
// 微信开放社区
|
||||||
router.get('/wechat-open/community/xcx-announce', require('./routes/wechat-open/community/xcx-announce'));
|
router.get('/wechat-open/community/:type', require('./routes/tencent/wechat/wechat-open/community/announce'));
|
||||||
router.get('/wechat-open/community/xyx-announce', require('./routes/wechat-open/community/xyx-announce'));
|
// 微信支付 - 商户平台公告
|
||||||
router.get('/wechat-open/community/pay-announce', require('./routes/wechat-open/community/pay-announce'));
|
router.get('/wechat-open/pay/announce', require('./routes/tencent/wechat/wechat-open/pay/announce'));
|
||||||
router.get('/wechat-open/pay/announce', require('./routes/wechat-open/pay/announce'));
|
router.get('/wechat-open/community/:type/:category', require('./routes/tencent/wechat/wechat-open/community/question'));
|
||||||
router.get('/wechat-open/community/xyx-question/:category', require('./routes/wechat-open/community/xyx-question'));
|
|
||||||
router.get('/wechat-open/community/xcx-question/:tag', require('./routes/wechat-open/community/xcx-question'));
|
|
||||||
|
|
||||||
// 微店
|
// 微店
|
||||||
router.get('/weidian/goods/:id', require('./routes/weidian/goods'));
|
router.get('/weidian/goods/:id', require('./routes/weidian/goods'));
|
||||||
@@ -2154,7 +2152,7 @@ router.get('/scala/blog/:part?', require('./routes/scala-blog/scala-blog'));
|
|||||||
router.get('/minecraft/version', require('./routes/minecraft/version'));
|
router.get('/minecraft/version', require('./routes/minecraft/version'));
|
||||||
|
|
||||||
// 微信更新日志
|
// 微信更新日志
|
||||||
router.get('/weixin/miniprogram/release', require('./routes/weixinMiniprogram/release')); // 基础库更新
|
router.get('/weixin/miniprogram/release', require('./routes/tencent/wechat/miniprogram/release')); // 基础库更新
|
||||||
|
|
||||||
// 武汉肺炎疫情动态
|
// 武汉肺炎疫情动态
|
||||||
router.get('/coronavirus/caixin', require('./routes/coronavirus/caixin'));
|
router.get('/coronavirus/caixin', require('./routes/coronavirus/caixin'));
|
||||||
|
|||||||
@@ -2,9 +2,22 @@ const got = require('@/utils/got');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
|
let { type } = ctx.params;
|
||||||
|
let title = '微信开放社区 - ';
|
||||||
|
if (type.startsWith('pay')) {
|
||||||
|
type = 'pay';
|
||||||
|
title += '微信支付公告';
|
||||||
|
} else if (type.startsWith('xcx')) {
|
||||||
|
type = 'develop';
|
||||||
|
title += '小程序公告';
|
||||||
|
} else if (type.startsWith('xyx')) {
|
||||||
|
type = 'minigame';
|
||||||
|
title += '小游戏公告';
|
||||||
|
}
|
||||||
|
const link = `https://developers.weixin.qq.com/community/${type}/list/2`;
|
||||||
const { data: htmlString } = await got({
|
const { data: htmlString } = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: 'https://developers.weixin.qq.com/community/pay/list/2',
|
url: link,
|
||||||
});
|
});
|
||||||
const $ = cheerio.load(htmlString);
|
const $ = cheerio.load(htmlString);
|
||||||
const announceList = [];
|
const announceList = [];
|
||||||
@@ -23,8 +36,8 @@ module.exports = async (ctx) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: '微信开放社区-微信支付公告',
|
title,
|
||||||
link: 'https://developers.weixin.qq.com/community/pay/list/2',
|
link,
|
||||||
item: announceList,
|
item: announceList,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1,25 +1,27 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const category = ctx.params.category;
|
const { type, category } = ctx.params;
|
||||||
|
let url, title;
|
||||||
|
if (type.startsWith('xcx')) {
|
||||||
|
url = `https://developers.weixin.qq.com/community/ngi/question/list?page=1&tag=${category}`;
|
||||||
|
title = `微信开放社区的小程序问题 - ${category}`;
|
||||||
|
} else if (type.startsWith('xyx')) {
|
||||||
|
url = `https://developers.weixin.qq.com/community/ngi/timeline/2/1/${category}?page=1&limit=10`;
|
||||||
|
title = `微信开放社区的小游戏问题 - ${category}`;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await got({
|
const response = await got.get(url);
|
||||||
method: 'get',
|
|
||||||
url: `https://developers.weixin.qq.com/community/ngi/timeline/2/1/${category}?page=1&limit=10`,
|
|
||||||
headers: {
|
|
||||||
Referer: `https://developers.weixin.qq.com/community/minigame/question?type=${category}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = response.data.data;
|
const data = response.data.data;
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
// 源标题
|
// 源标题
|
||||||
title: `微信开放社区的小程序问题 - ${category}`,
|
title,
|
||||||
// 源链接
|
// 源链接
|
||||||
link: `https://developers.weixin.qq.com/community/develop/question?tag=${category}`,
|
link: url,
|
||||||
// 源说明
|
// 源说明
|
||||||
description: `微信开放社区的小程序问题 - ${category}`,
|
description: title,
|
||||||
// 遍历此前获取的数据
|
// 遍历此前获取的数据
|
||||||
item: data.rows.map((item) => ({
|
item: data.rows.map((item) => ({
|
||||||
// 文章标题
|
// 文章标题
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
const got = require('@/utils/got');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const { data: htmlString } = await got({
|
|
||||||
method: 'get',
|
|
||||||
url: 'https://developers.weixin.qq.com/community/develop/list/2',
|
|
||||||
});
|
|
||||||
const $ = cheerio.load(htmlString);
|
|
||||||
const announceList = [];
|
|
||||||
$('#article_frame > div > ul > li').each(function() {
|
|
||||||
const $item = $(this);
|
|
||||||
const $link = $item.find('a').attr('href');
|
|
||||||
const time = $item.find('div > em').text();
|
|
||||||
const title = $item.find('h2 > meta').attr('content');
|
|
||||||
|
|
||||||
announceList.push({
|
|
||||||
title: title,
|
|
||||||
link: `https://developers.weixin.qq.com${$link}`,
|
|
||||||
description: title,
|
|
||||||
pubDate: time,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '微信开放社区-小程序公告',
|
|
||||||
link: 'https://developers.weixin.qq.com/community/develop/list/2',
|
|
||||||
item: announceList,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
const got = require('@/utils/got');
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const tag = ctx.params.tag;
|
|
||||||
|
|
||||||
const response = await got({
|
|
||||||
method: 'get',
|
|
||||||
url: `https://developers.weixin.qq.com/community/ngi/question/list?page=1&tag=${tag}`,
|
|
||||||
headers: {
|
|
||||||
Referer: `https://developers.weixin.qq.com/community/develop/question`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = response.data.data;
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
// 源标题
|
|
||||||
title: `微信开放社区的小程序问题 - ${tag}`,
|
|
||||||
// 源链接
|
|
||||||
link: `https://developers.weixin.qq.com/community/develop/question?tag=${tag}`,
|
|
||||||
// 源说明
|
|
||||||
description: `微信开放社区的小程序问题 - ${tag}`,
|
|
||||||
// 遍历此前获取的数据
|
|
||||||
item: data.rows.map((item) => ({
|
|
||||||
// 文章标题
|
|
||||||
title: item.Title,
|
|
||||||
// 文章正文
|
|
||||||
description: `${item.Content}`,
|
|
||||||
// 文章发布时间
|
|
||||||
pubDate: new Date(item.CreateTime * 1000).toUTCString(),
|
|
||||||
// 文章链接
|
|
||||||
link: `https://developers.weixin.qq.com/community/develop/doc/${item.DocId}`,
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
const got = require('@/utils/got');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const { data: htmlString } = await got({
|
|
||||||
method: 'get',
|
|
||||||
url: 'https://developers.weixin.qq.com/community/minigame/list/2',
|
|
||||||
});
|
|
||||||
const $ = cheerio.load(htmlString);
|
|
||||||
const announceList = [];
|
|
||||||
$('#article_frame > div > ul > li').each(function() {
|
|
||||||
const $item = $(this);
|
|
||||||
const $link = $item.find('a').attr('href');
|
|
||||||
const time = $item.find('div > em').text();
|
|
||||||
const title = $item.find('h2 > meta').attr('content');
|
|
||||||
|
|
||||||
announceList.push({
|
|
||||||
title: title,
|
|
||||||
link: `https://developers.weixin.qq.com${$link}`,
|
|
||||||
description: title,
|
|
||||||
pubDate: time,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '微信开放社区-小游戏公告',
|
|
||||||
link: 'https://developers.weixin.qq.com/community/minigame/list/2',
|
|
||||||
item: announceList,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user