feat: add xiaomi bbs
This commit is contained in:
parent
8f1af20eed
commit
77cb871113
|
|
@ -967,4 +967,15 @@
|
|||
},
|
||||
],
|
||||
},
|
||||
'xiaomi.cn': {
|
||||
_name: '小米社区',
|
||||
www: [
|
||||
{
|
||||
title: '圈子',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#xiao-mi-she-qu',
|
||||
source: '/board/:boardId',
|
||||
target: '/mi/bbs/board/:boardId',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -177,6 +177,12 @@ pageClass: routes
|
|||
|
||||
<Route author="u3u" example="/tieba/post/lz/5853240586" path="/tieba/post/lz/:id" :paramsDesc="['帖子 ID']"/>
|
||||
|
||||
## 小米社区
|
||||
|
||||
### 圈子
|
||||
|
||||
<Route author="DIYgod" example="/mi/bbs/board/18066617" path="/mi/bbs/board/:boardId" :paramsDesc="['圈子 id,可在圈子 URL 找到']" radar="1"/>
|
||||
|
||||
## 一亩三分地
|
||||
|
||||
### 主题帖
|
||||
|
|
|
|||
|
|
@ -371,8 +371,8 @@ router.get('/hexo/yilia/:url', require('./routes/hexo/yilia'));
|
|||
router.get('/mi/crowdfunding', require('./routes/mi/crowdfunding'));
|
||||
router.get('/mi/youpin/crowdfunding', require('./routes/mi/youpin/crowdfunding'));
|
||||
router.get('/mi/youpin/new', require('./routes/mi/youpin/new'));
|
||||
// MIUI 更新
|
||||
router.get('/miui/:device/:type?/:region?', require('./routes/mi/miui/index'));
|
||||
router.get('/mi/bbs/board/:boardId', require('./routes/mi/board'));
|
||||
|
||||
// Keep
|
||||
router.get('/keep/user/:id', require('./routes/keep/user'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const boardId = ctx.params.boardId;
|
||||
const link = `https://www.xiaomi.cn/board/${boardId}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://prod.api.xiaomi.cn/community/board/home/announce/list?after=&limit=20&boardId=${boardId}`,
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
const data = response.data.entity.records;
|
||||
const name = data && data[0].boards[0].boardName;
|
||||
|
||||
ctx.state.data = {
|
||||
title: name + '-小米社区',
|
||||
link: link,
|
||||
item: data.map((item) => {
|
||||
let picTpl = '';
|
||||
if (item.picList && item.picList.length) {
|
||||
item.picList.forEach((pic) => {
|
||||
picTpl += `<br><img src="${pic.imageUrl}">`;
|
||||
});
|
||||
}
|
||||
return {
|
||||
title: item.title || item.textContent,
|
||||
description: item.textContent + picTpl,
|
||||
pubDate: new Date(item.createTime).toUTCString(),
|
||||
author: item.author.name,
|
||||
link: `https://www.xiaomi.cn/post/${item.id}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue