fix(route): 二柄APP (#7799)

Co-authored-by: auto-bot-ty <75887908+auto-bot-ty@users.noreply.github.com>
Co-authored-by: auto-bot-ty <1093034894@qq.com>
This commit is contained in:
wushijishan 2021-07-17 17:11:04 +08:00 committed by GitHub
parent fc0d6f131e
commit b023b6034e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 29 deletions

View File

@ -1,42 +1,51 @@
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
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;
const data = JSON.parse(response.body).feeds;
const items = data.map((item) => {
let description = `<p>${item.content}</p>`;
const acontent = item.acontent.toString();
const ProcessDesc = (link, type) => {
if (type) {
description += `<p><a href="${link}">More</a></p>`;
} else {
for (const item of link) {
description += `<p><img src="${item}"></p>`;
}
}
};
if (item.video_img !== null) {
ProcessDesc([item.video_img]);
} else if (acontent.indexOf('104129') !== -1) {
ProcessDesc([item.article.humb.split('?')[0]]);
} else if (acontent.indexOf('.html') !== -1) {
ProcessDesc([acontent], 'html');
} else if (acontent.indexOf('"imgs') !== -1) {
const imgs = JSON.parse(acontent).imgs.split(',');
ProcessDesc(imgs);
} else {
const imgs = acontent.split(',');
ProcessDesc(imgs);
}
return {
title: item.title,
link: item.share.url,
description,
pubDate: timezone(parseDate(item.create_time), +8),
};
});
ctx.state.data = {
title: `二柄APP`,
link: `https://www.diershoubing.com/`,
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 if (item.acontent.indexOf('104129') !== -1) {
description += `<br><img src="${item.article.humb.split('?')[0]}">`;
} else if (item.acontent.indexOf('.html') !== -1) {
description += `<br><a href="${item.acontent}">More</a>`;
} else if (item.acontent.indexOf('"imgs') !== -1) {
const imgs = item.acontent.split(',');
for (let i = 1; i < imgs.length; i++) {
description += `<br><img src="${imgs[i]}">`;
}
} 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,
};
}),
item: items,
};
};