mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: 添加飞地用户创作和用户收藏 (#2713)
This commit is contained in:
@@ -491,6 +491,14 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
|
|
||||||
<Route author="LogicJake" example="/enclavebooks/category/1" path="/enclavebooks/category/:id" :paramsDesc="['类别 id,可在[分类api](https://app.enclavebooks.cn/v2/discovery)返回数据中的category查看']"/>
|
<Route author="LogicJake" example="/enclavebooks/category/1" path="/enclavebooks/category/:id" :paramsDesc="['类别 id,可在[分类api](https://app.enclavebooks.cn/v2/discovery)返回数据中的category查看']"/>
|
||||||
|
|
||||||
|
### 用户创作
|
||||||
|
|
||||||
|
<Route author="junbaor" example="/enclavebooks/user/103702" path="/enclavebooks/user/:uid" :paramsDesc="['用户ID, 自行抓包寻找']"/>
|
||||||
|
|
||||||
|
### 用户收藏
|
||||||
|
|
||||||
|
<Route author="junbaor" example="/enclavebooks/collection/103702" path="/enclavebooks/collection/:uid" :paramsDesc="['用户ID, 自行抓包寻找']"/>
|
||||||
|
|
||||||
## 福利资源-met.red
|
## 福利资源-met.red
|
||||||
|
|
||||||
### 福利资源-met.red
|
### 福利资源-met.red
|
||||||
|
|||||||
@@ -1372,6 +1372,8 @@ router.get('/yuque/doc/:repo_id', require('./routes/yuque/doc'));
|
|||||||
|
|
||||||
// 飞地
|
// 飞地
|
||||||
router.get('/enclavebooks/category/:id?', require('./routes/enclavebooks/category'));
|
router.get('/enclavebooks/category/:id?', require('./routes/enclavebooks/category'));
|
||||||
|
router.get('/enclavebooks/user/:uid', require('./routes/enclavebooks/user.js'));
|
||||||
|
router.get('/enclavebooks/collection/:uid', require('./routes/enclavebooks/collection.js'));
|
||||||
|
|
||||||
// 色花堂 - 色花图片版块
|
// 色花堂 - 色花图片版块
|
||||||
router.get('/dsndsht23/picture/:subforumid', require('./routes/dsndsht23/pictures'));
|
router.get('/dsndsht23/picture/:subforumid', require('./routes/dsndsht23/pictures'));
|
||||||
|
|||||||
44
lib/routes/enclavebooks/collection.js
Normal file
44
lib/routes/enclavebooks/collection.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const uid = ctx.params.uid;
|
||||||
|
|
||||||
|
const authorUrl = 'https://app.enclavebooks.cn/v2/getOtherUserInformation?otherUserId%5B%5D=' + uid;
|
||||||
|
const authorResponse = await got(authorUrl);
|
||||||
|
const autherName = authorResponse.data.result[0].nickname;
|
||||||
|
|
||||||
|
const url = 'https://app.enclavebooks.cn/v2/getCollectionList?page=1&userId=' + uid;
|
||||||
|
const response = await got({ method: 'get', url });
|
||||||
|
const responseList = response.data.result.data;
|
||||||
|
|
||||||
|
const list = responseList.map((item) => ({
|
||||||
|
artId: item.artId,
|
||||||
|
title: item.artTitle,
|
||||||
|
description: item.artDescription,
|
||||||
|
// pubDate: new Date(item.artTime * 1000).toUTCString(),// 收藏顺序不是文章的创作时间
|
||||||
|
link: `http://www.enclavebooks.cn/article.html?art_id=${item.artId}`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const link = 'https://app.enclavebooks.cn/v2/article?id=' + item.artId;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemReponse = await got.get(link);
|
||||||
|
item.description = itemReponse.data.result.artContent;
|
||||||
|
|
||||||
|
ctx.cache.set(link, JSON.stringify(item));
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '飞地 - ' + autherName + '的收藏',
|
||||||
|
link: url,
|
||||||
|
item: result.reverse(),
|
||||||
|
};
|
||||||
|
};
|
||||||
44
lib/routes/enclavebooks/user.js
Normal file
44
lib/routes/enclavebooks/user.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const uid = ctx.params.uid;
|
||||||
|
|
||||||
|
const authorUrl = 'https://app.enclavebooks.cn/v2/getOtherUserInformation?otherUserId%5B%5D=' + uid;
|
||||||
|
const authorResponse = await got(authorUrl);
|
||||||
|
const autherName = authorResponse.data.result[0].nickname;
|
||||||
|
|
||||||
|
const url = 'https://app.enclavebooks.cn/v2/writeListByOther?page=1&otherUserId=' + uid;
|
||||||
|
const response = await got({ method: 'get', url });
|
||||||
|
const responseList = response.data.result.data;
|
||||||
|
|
||||||
|
const list = responseList.map((item) => ({
|
||||||
|
artId: item.artId,
|
||||||
|
title: item.artTitle,
|
||||||
|
description: item.artDescription,
|
||||||
|
pubDate: new Date(item.artTime * 1000).toUTCString(),
|
||||||
|
link: `http://www.enclavebooks.cn/article.html?art_id=${item.artId}`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const link = 'https://app.enclavebooks.cn/v2/article?id=' + item.artId;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemReponse = await got.get(link);
|
||||||
|
item.description = itemReponse.data.result.artContent;
|
||||||
|
|
||||||
|
ctx.cache.set(link, JSON.stringify(item));
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '飞地 - ' + autherName,
|
||||||
|
link: url,
|
||||||
|
item: result,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user