diff --git a/docs/README.md b/docs/README.md index 153aa059ae..39cb262ab0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2373,3 +2373,9 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 | Mac | Google | Toys | + +### 刷屏 + + + + diff --git a/router.js b/router.js index 1d5c6770f5..4617b4c0aa 100644 --- a/router.js +++ b/router.js @@ -821,4 +821,8 @@ router.get('/idownloadblog', require('./routes/idownloadblog/index')); // 9to5 router.get('/9to5/:type', require('./routes/9to5/subsite')); +// 刷屏 +router.get('/weseepro/newest', require('./routes/weseepro/newest')); +router.get('/weseepro/circle', require('./routes/weseepro/circle')); + module.exports = router; diff --git a/routes/weseepro/circle.js b/routes/weseepro/circle.js new file mode 100644 index 0000000000..d8c0bd4370 --- /dev/null +++ b/routes/weseepro/circle.js @@ -0,0 +1,38 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + url: 'https://www.weseepro.com/api/v1/message/stream/circle/2?end_uuid=&field_uuid=hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh', + }); + + const data = response.data.data.field_messages; + + ctx.state.data = { + title: '刷屏-朋友圈', + link: 'https://www.weseepro.com', + item: data.map((item) => { + const description = `${item.message.account.name}: ${item.message.message_text.content}`; + let imgs = ''; + + if (item.message.link) { + imgs = item.message.link.url.split(',').reduce((imgs, img) => { + imgs += ` + + `; + return imgs; + }, ''); + } + + return { + title: description, + link: `https://www.weseepro.com/v/ask?uuid=${item.message_uuid}`, + description: ` + ${description}

+ ${imgs} + `, + pubDate: new Date(item.message.message_text.add_time).toUTCString(), + }; + }), + }; +}; diff --git a/routes/weseepro/newest.js b/routes/weseepro/newest.js new file mode 100644 index 0000000000..492e695178 --- /dev/null +++ b/routes/weseepro/newest.js @@ -0,0 +1,59 @@ +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) => ` +

+ ${message.link.summary}

+ ${message.topMessage.account.name}: ${message.topMessage.content.replace(/\n/g, '
')}

+ `; + + 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 = `https://www.weseepro.com/mine/article?uuid=${spam.uuid}`; + 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 = ` +

+ ${special.description}

+ ${messages} + `; + } else { + title = description = '未知类型,请点击链接提交issue'; + } + + return { + title, + link, + description, + pubDate, + }; + }), + }; +};