feat: 增加二柄APP新闻 (#5081)

This commit is contained in:
wushijishan
2020-06-29 01:12:25 +08:00
committed by GitHub
parent c21b66ffc8
commit f319d075e1
3 changed files with 42 additions and 0 deletions

View File

@@ -461,3 +461,9 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
### 游戏横幅
<Route author="y2361547758" example="/magireco/event_banner" path="/magireco/event_banner"/>
## 二柄APP
### 新闻
<Route author="wushijishan" example="/erbingapp/news" path="/erbingapp/news"/>

View File

@@ -2896,6 +2896,9 @@ router.get('/go-weekly', require('./routes/go-weekly'));
// AMD
router.get('/amd/graphicsdrivers/:id/:rid?', require('./routes/amd/graphicsdrivers'));
// 二柄APP
router.get('/erbingapp/news', require('./routes/erbingapp/news'));
// 电商报
router.get('/dsb/area/:area', require('./routes/dsb/area'));

View File

@@ -0,0 +1,33 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: `https://api.diershoubing.com:5001/feed/tag/?pn=0&rn=20&tag_type=0&src=ios`,
resolveBodyOnly: true,
responseType: 'json',
});
const data = response.feeds;
ctx.state.data = {
title: `二柄APP`,
link: `https://www.diershoubing.com/`,
description: `二柄APP新闻`,
item: data.map((item) => {
let description = item.content;
if (item.video_img !== null) {
description += `<br><img src="${item.video_img}">`;
} else {
const imgs = item.acontent.split(',');
for (let i = 0; i < imgs.length; i++) {
description += `<br><img src="${imgs[i]}">`;
}
}
return {
description,
link: item.share.url,
title: item.title,
};
}),
};
};