fix(route): fix taobao/zhongchou route is empty and refactor to V2 standard (#8958)

This commit is contained in:
Fatpandac 2022-02-02 23:53:29 +08:00 committed by GitHub
parent 19bd0bc5cc
commit 6bf09c868d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 134 additions and 11 deletions

View File

@ -312,7 +312,7 @@ For instance, in <https://www.leboncoin.fr/recherche/?**category=10&locations=Pa
### 众筹项目
<Route author="xyqfer" example="/taobao/zhongchou/all" path="/taobao/zhongchou/:type?" :paramsDesc="['类型, 默认为 `all` 全部']">
<Route author="xyqfer Fatpandac" example="/taobao/zhongchou/all" path="/taobao/zhongchou/:type?" :paramsDesc="['类型, 默认为 `all` 全部']">
| 全部 | 科技 | 食品 | 动漫 | 设计 | 公益 | 娱乐 | 影音 | 书籍 | 游戏 | 其他 |
| ---- | ---- | ----------- | ---- | ------ | ---- | ---- | ----- | ---- | ---- | ----- |

View File

@ -1247,9 +1247,6 @@ router.get('/patchwork.kernel.org/comments/:id', lazyloadRouteHandler('./routes/
// 京东众筹
router.get('/jingdong/zhongchou/:type/:status/:sort', lazyloadRouteHandler('./routes/jingdong/zhongchou'));
// 淘宝众筹
router.get('/taobao/zhongchou/:type?', lazyloadRouteHandler('./routes/taobao/zhongchou'));
// All Poetry
router.get('/allpoetry/:order?', lazyloadRouteHandler('./routes/allpoetry/order'));

View File

@ -0,0 +1,3 @@
module.exports = {
'/zhongchou/:type?': ['xyqfer', 'Fatpandac'],
};

117
lib/v2/taobao/radar.js Normal file
View File

@ -0,0 +1,117 @@
module.exports = {
'taobao.com': {
_name: '淘宝',
izhongchou: [
{
title: '淘宝众筹全部',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '') {
return '/taobao/zhongchou/all';
}
},
},
{
title: '淘宝众筹科技',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '121288001') {
return '/taobao/zhongchou/tech';
}
},
},
{
title: '淘宝众筹食品',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '123330001,125672021') {
return '/taobao/zhongchou/agriculture';
}
},
},
{
title: '淘宝众筹动漫',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '122018001') {
return '/taobao/zhongchou/acg';
}
},
},
{
title: '淘宝众筹设计',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '121292001,126176002,126202001') {
return '/taobao/zhongchou/design';
}
},
},
{
title: '淘宝众筹公益',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '121280001') {
return '/taobao/zhongchou/love';
}
},
},
{
title: '淘宝众筹娱乐',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '121284001') {
return '/taobao/zhongchou/tele';
}
},
},
{
title: '淘宝众筹影音',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '121278001') {
return '/taobao/zhongchou/music';
}
},
},
{
title: '淘宝众筹书籍',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '121274002') {
return '/taobao/zhongchou/book';
}
},
},
{
title: '淘宝众筹游戏',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '122020001') {
return '/taobao/zhongchou/game';
}
},
},
{
title: '淘宝众筹其他',
docs: 'https://docs.rsshub.app/shopping.html#tao-bao-zhong-chou-zhong-chou-xiang-mu',
source: ['/list.htm'],
target: (params, url) => {
if (new URLSearchParams(new URL(url).search).get('type') === '125706031,125888001,125886001,123332001') {
return '/taobao/zhongchou/other';
}
},
},
],
},
};

3
lib/v2/taobao/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/zhongchou/:type?', require('./zhongchou'));
};

View File

@ -0,0 +1,4 @@
<img src="{{item.image}}"><br><br>
<strong>达成率:</strong> {{item.finish_per}}%<br>
<strong>已筹金额:</strong> {{item.curr_money}}元<br>
<strong>支持人数:</strong> {{item.buy_amount}}<br>

View File

@ -1,4 +1,6 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const { type = 'all' } = ctx.params;
@ -15,7 +17,7 @@ module.exports = async (ctx) => {
game: '122020001',
other: '125706031,125888001,125886001,123332001',
};
const url = `https://izhongchou.taobao.com/dream/ajax/getProjectList.htm?page=1&pageSize=20&projectType=${encodeURIComponent(map[type])}&type=6&status=&sort=1&_ksTS=${Date.now()}_104&callback=`;
const url = `https://izhongchou.taobao.com/dream/ajax/getProjectListNew.htm?_input_charset=utf-8&type=6&pageSize=20&page=1&sort=1&status=&projectType=${encodeURIComponent(map[type])}&_=${Date.now()}&callback=`;
const response = await got({
method: 'get',
url,
@ -24,12 +26,9 @@ module.exports = async (ctx) => {
const items = response.data.data.map((item) => {
const title = item.name;
const link = `https://izhongchou.taobao.com/dreamdetail.htm?id=${item.id}`;
const description = `
<img src="https:${item.image}"><br><br>
<strong>达成率:</strong> ${item.finish_per}%<br>
<strong>已筹金额:</strong> ${item.curr_money}<br>
<strong>支持人数:</strong> ${item.buy_amount}<br>
`;
const description = art(path.join(__dirname, 'templates/zhongchou.art'), {
item,
});
return {
title,