add: 「刷屏-最新」路由无中间页版 (#1747)

item 链接改为 文章原文链接,不看中间页
This commit is contained in:
Jonathan Gongye
2019-03-15 14:20:49 +08:00
committed by DIYgod
parent 58065a39aa
commit 2a0e9f8431
3 changed files with 71 additions and 1 deletions

View File

@@ -3038,7 +3038,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
### 刷屏
<route name="最新" author="xyqfer" example="/weseepro/newest" path="/weseepro/newest"/>
<route name="最新(无中间页)" author="xyqfer yefoenix" example="/weseepro/newest-direct" path="/weseepro/newest-direct"/>
<route name="朋友圈" author="xyqfer" example="/weseepro/circle" path="/weseepro/circle"/>
### 虎嗅

View File

@@ -933,6 +933,7 @@ router.get('/testerhome/newest', require('./routes/testerhome/newest'));
// 刷屏
router.get('/weseepro/newest', require('./routes/weseepro/newest'));
router.get('/weseepro/newest-direct', require('./routes/weseepro/newest-direct'));
router.get('/weseepro/circle', require('./routes/weseepro/circle'));
// 玩物志

View File

@@ -0,0 +1,69 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'https://www.weseepro.com/api/v1/message/ground/spam?pageNumber=1&pageSize=20',
});
const data = response.data.data.data;
const generateMessage = (message) => {
let name = '';
let content = '';
if (message.topMessage.account) {
name = message.topMessage.account.name;
content = message.topMessage.content.replace(/\n/g, '<br>');
}
return `
<img referrerpolicy="no-referrer" src="${message.link.img_url}"/><br><br>
<a href="${message.link.url}">${message.link.summary}</a><br><br>
<strong>${name}</strong>: ${content}<br><br>
`;
};
ctx.state.data = {
title: '刷屏-最新(无中间页)',
link: 'https://www.weseepro.com',
item: data.map((item) => {
let title;
let link;
let description;
let pubDate;
if (item.data.spam) {
const spam = item.data.spam;
title = spam.content;
link = spam.link.url;
description = generateMessage(spam);
pubDate = new Date(spam.spam_add_time).toUTCString();
} else if (item.data.special) {
const special = item.data.special;
const specialMessages = item.data.special_messages;
const messages = specialMessages.reduce((messages, message) => {
messages += generateMessage(message);
return messages;
}, '');
title = special.title;
link = `https://www.weseepro.com/mine/album?uuid=${special.uuid}`;
description = `
<img referrerpolicy="no-referrer" src="${special.image}"/><br><br>
${special.description}<br><br>
${messages}
`;
} else {
title = description = '未知类型,请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue';
}
return {
title,
link,
description,
pubDate,
};
}),
};
};