feat: add 腾讯柠檬精选 (#5066)

This commit is contained in:
Henry Wang
2020-06-28 04:20:10 +01:00
committed by GitHub
parent 568184b911
commit 4b51ba54f4
4 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
const got = require('@/utils/got');
const date = require('@/utils/date');
module.exports = async (ctx) => {
const url = 'https://lemon.qq.com/lab/js/source.js';
let data = (await got.get(url)).data.match(/(?<=(var list = ))(.*)(\])/gs)[0];
// eslint-disable-next-line no-eval
data = eval('(' + data + ')').slice(0, 10);
const items = data.map((i) => ({
title: i.name,
description: `
${i.comment}</br>
<img src="${i.logo}"></br>
<a href="${i.downloadlink}">下载链接</a>
`,
link: `https://lemon.qq.com/lab/app/${i.shortname}.html`,
author: i.referrer,
pubDate: date(i.date),
}));
ctx.state.data = {
title: '腾讯柠檬精选',
link: 'https://lemon.qq.com/lab/',
item: items,
};
};